Jump to content


Data from 3 Dropdown Menus Into 1 Table Field?

  • Please log in to reply
1 reply to this topic

#1 Unholy Prayer

Unholy Prayer
  • Members
  • PipPipPip
  • Advanced Member
  • 166 posts

Posted 13 September 2006 - 11:29 PM

Ok, I'm making a member registration form and I have a field for their date of birth.  I have 3 different drop down menus for it:  one for the month they were born in, one for the day the were born on, and one for the year they were born in.  How do I make it so it will insert the data from all three dropdown menus into one table field? 

#2 HuggieBear

  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 11:41 PM

You need to get the values into php like so:

  $day = $_GET['day']; // The bit inside the single quote is your HTML field name
  $month = $_GET['month']; // and the GET would be changed to POST depending on the method you're using
  $year = $_GET['year'];

  $date = $year . "-" . $month . "-" . $day; // . (dot) is the concatenation symbol

Then just use $date to insert into your date field in the database.

Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users