Jump to content

not echoing out selected dob


runnerjp

Recommended Posts

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;

 

??

Link to comment
https://forums.phpfreaks.com/topic/106305-not-echoing-out-selected-dob/
Share on other sites

but what im doing is i want to pull for the db what the user selected the last time they where inserting there dob... for example my gender is

<select class="input" id="gender" name="gender">

<option value="Male" <?php if($gender == 'Male') echo 'selected'; ?>>Male</option>

<option value="Female"  <?php if($gender == 'Female') echo 'selected'; ?>>Female</option>

</select>

 

so if i selected male it will show male in the table..and does

 

but i add the gender into the database... so i can pull out gender... but

 

when i insert dob into the db i use $dob = $birthday.'-'.$birthmonth.'-'.$birthyear; so in my db i just have $dob so i can only echo $dob from my table yes....

right if $dob is whatever you pulled out of the database, the you need to seperate it into $day $month and $year. but i assumed you already did that since you were saying

 

if $birthmonth == something etc etc

 

$birthmonth needs to be only the month part of whatever you pulled from the db for it to work.

 

if youre saying the following:

 

if ($birthmonth == "december"){

 

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.