i have a field on database with mysql called birthdate i divided it into 3 fields year month day because on the form i put a comobo box to the year and combo box to day and other to month and put every value on field but i want to but from this three combobox on one field called birthdate how i can do that please help me thank you
OK, so say you have the three combo boxes, retrieve a value from each of them: Example HTML: <select name='day'>Options<select> <select name='month'>Options<select> <select name='year'>Options<select> Code (markup): PHP //Declare the variables $day = $_POST['day']; $month = $_POST['month']; $year = $_POST['year']; //Create an array $dateparts = array($month,$day,$year); $date = implode("-",$dateparts); PHP: Then $date is equal to month-day-year, which if I am not mistaken is the same syntax as MySQL DATE. BP
I believe the code above works but why use so many variables? It can be as simple as this: $date = $_POST['year'] . '-' . $_POST['month'] . '-' . $_POST['day']; PHP:
I always like to keep $_POST['variables'] as $variables, in case I need to use them later, and don't wish to retype $_POST['variables'] every time. And I used implode cause I've never had a reason to use it before