Can PHP assign the value of the drop-down list to a date field in the database? part of the form code
**************************************** ******************************* *******
Echo' ';Echo"Select";Foreach ($ year as $ value ){Echo"$ Value";}Echo'Year ';
******** **************************************** ********
?>
Code for form verification
**************************************** ************************************* Is omitted *************************************** *********
If ($ _ POST ['Year']! = Select & $ _ POST ['month']! = Select & $ _ POST ['day']! = Select)
$ Birthday = $ _ POST ['Year']. $ _ POST ['month']. $ _ POST ['day'];
Else array_push ($ errors, 'select the birthdate ');
If (! Empty ($ _ POST ['initduct ']) $ introduction = $ _ POST ['initduct'];
**************************************** ************************************ *************
?>
The problem now is that I want to save $ birthday to the database data type field, but the value passed in is always 0000-00-00, unless I change the data type to bytes, I just learned PHP. please help me.
Reply to discussion (solution)
Save it with a timestamp and change the time type to the int type. When saving the data as follows:
$date=stetotime($birthday);
Save it with a timestamp and change the time type to the int type. When saving the data as follows:
$date=stetotime($birthday);
$date=strtotime($birthday);
Error.
$ Birthday = $ _ POST ['Year']. '-'. $ _ POST ['month']. '-'. $ _ POST ['day'];
@ Xuzuning: it turns out this way. it's easier than the first floor. However, your method is also quite good. @ XXOOme. thank you for your help !!