Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

mysql handling Date of Births

Options
  • 17-01-2009 6:55pm
    #1
    Registered Users Posts: 3,875 ✭✭✭


    Hello,
    whats is the best way of entering a date of birth from a form into a mysql database

    I would like to use three combo boxes as in day month and year,
    but I do not know how to input the results of all three boxes into mysql and also how to validate this,

    does anyone have any ideas,

    or even just how to validate a text field in the dd-mm-yyyy format

    cheers.


Comments

  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,178 Mod ✭✭✭✭Jonathan


    This for school/college?


  • Registered Users Posts: 3,875 ✭✭✭ShoulderChip


    its for a database website I am building for a friend, I am just realising I may not even need to do it this way I could just have the three combo boxes as I dont have a need for calculating age

    my one question then would be how can I allow the year field to start on todays year and go back 100 hundred years?
    that way it would be future proof.


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,178 Mod ✭✭✭✭Jonathan


    Sounds to me like you are talking about php rather than sql.


  • Registered Users Posts: 8,488 ✭✭✭Goodshape


    Actually working on something similar this very minute.

    Here's what works for me, maybe you can use it or adapt it.

    [php]

    $day = $_GET["day"];
    $month = $_GET["month"];
    $year = $_GET["year"];
    $hour = $_GET["hour"];
    $minute = $_GET["minute"];

    $values = "$year-$month-$day $hour:$minute:00";
    [/php]

    That final $values is ready to be put into MySQL. That's the format used.


  • Registered Users Posts: 3,875 ✭✭✭ShoulderChip


    cheers thanks for that

    I am having one other very short problem

    I am displaying a table of records, yet i want the user to have the option to filter it

    so i have set up a combo list to decide what they want to filter it on (job title etc)

    I then have a submit button which submits the form
    i then have a second submit button which links to the second page with the result of the combo box attached as an form parameter

    My problem is it only works if i click submit 1 and then submit 2 i have tried everything to get a single submit button to post the form and then link to the page with the form parameter but with no link


  • Advertisement
  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    for outputting the year selector:

    [php]
    <?

    $current_year=date('Y');
    $earliest_year=$current_year-101;

    for($year=$current_year; $year>$earliest_year; $year--) {
    $options.="<option value='$year'>$year</option>";
    }

    ?>

    <select>
    <?= $options; ?>
    </select>
    [/php]


  • Registered Users Posts: 3,875 ✭✭✭ShoulderChip


    Edit I figured out the two submit buttons.
    cheers.


Advertisement