How do I write functions for updating the year, month, and day? It didn't take long for me to get started with PHP. I 'd like to ask you,
There is a data table,
The content of the birthday field is 1989-11-28
The ageyear field is year.
The agemonth field is month.
The ageday field is day
I want to write a statement to read the content in birthday and write it into the fields of year, month, and day.
What is the hybrid write class of this statement?
All in a data table
Even if you execute this function three times separately
Which eldest brother can help write for me?
You can write an SQL statement or PHP execution file. you only need to implement this function. thank you.
In addition, I would like to ask another SQL update statement to update the specified content in a table and change it to other content. for example, I want to change 2 in field 123 to 3. thank you.
Reply to discussion (solution)
Query this table using a select statement to obtain the birthday table ..
$ Birthday = $ row ["birthaday"]
$ Array = explode ("-", $ birthday)
$ Year = $ array [1]
$ Mon = $ array [2]
$ Day = $ array [3]
Update again
Query this table using a select statement to obtain the birthday table ..
$ Birthday = $ row ["birthaday"]
$ Array = explode ("-", $ birthday)
$ Year = $ array [1]
$ Mon = $ array [2]
$ Day = $ array [3]
Update again
Well. This method is good. But how should we execute it? Is it a separate PHP file? And create a new table?
Update data table set ageyear = left (birthday, 4), agemonth = substring (birthday, instr (birthday, '-') + 1, 2), ageday = right (birthday, 2 );
Update tb set field = replace (field, '2', '3 ');
Update data table set ageyear = left (birthday, 4), agemonth = substring (birthday, instr (birthday, '-') + 1, 2), ageday = right (birthday, 2 );
Update tb set field = replace (field, '2', '3 ');
Thanks for the success,