View Full Version : not echoing selected date in db

05-19-2008, 03:41 PM
ok i have my table set out like so

<label for="birthmonth">Birth Month:</label>
<select class="input" name="birthmonth" id="birthmonth">
<option value="January" <?php if($birthmonth == 'January') echo 'selected'; ?>>January</option>
<option value="Febuary" <?php if($birthmonth == 'Febuary') echo 'selected'; ?>>Febuary</option>
<option value="March" <?php if($birthmonth == 'March') echo 'selected'; ?>>March</option>
<option value="April" <?php if($birthmonth == 'April') echo 'selected'; ?>>April</option>
<option value="May" <?php if($birthmonth == 'May') echo 'selected'; ?>>May</option>
<option value="June" <?php if($birthmonth == 'June') echo 'selected'; ?>>June</option>
<option value="July" <?php if($birthmonth == 'July') echo 'selected'; ?>>July</option>
<option value="August" <?php if($birthmonth == 'August') echo 'selected'; ?>>August</option>
<option value="September" <?php if($birthmonth == 'September') echo 'selected'; ?>>September</option>
<option value="October" <?php if($birthmonth == 'October') echo 'selected'; ?>>October</option>
<option value="November" <?php if($birthmonth == 'November') echo 'selected'; ?>>November</option>
<option value="December" <?php if($birthmonth == 'December') echo 'selected'; ?>>December</option>

what should happen is the previous selected dob is echod but its not... culd it be that i join them all together like so

$birthyear = mysql_real_escape_string( $_POST['birthyear']);
$birthmonth = mysql_real_escape_string( $_POST['birthmonth']);
$birthday = mysql_real_escape_string( $_POST['birthday']);
$dob = $birthday.'-'.$birthmonth.'-'.$birthyear;


05-19-2008, 03:51 PM
Have you actually echo'd $birthmonth to see if it matches any of those cases - doing so might be revealing...

05-19-2008, 03:53 PM
yes i do... 19-December-1987 for example is what i get

05-19-2008, 03:58 PM
when you echo $birthmonth? Well, how is that ever supposed to match one of your if conditions? That echo looks more like the output of $dob thou.

05-19-2008, 04:35 PM
woops sorry ok i selected December and it echo'd December
as well as 19 been 19 and 1987 been 1987

05-19-2008, 05:48 PM
So, is this solved?

05-19-2008, 05:51 PM
runnerjp, use some loops to check/print the options.

05-19-2008, 05:57 PM
its printing everything fine tho lol just not in the text boxes... im thinking that maybe its because its stored as $dob = $birthday.'-'.$birthmonth.'-'.$birthyear; would i have to break it down again or something?