Jump to content

drop down box for male/female gender


pouncer

Recommended Posts

Here is how the drop down is

<select name="sel_Gender" class="style15" id="sel_Gender">
                                <option value="Male" selected>Male</option>
                                <option value="Female">Female</option>
                              </select>

It's on Male by default.

but i need to put in there somewhere this:

<?php echo $profile->Get_Gender(); ?>

which gives either male/female, and how could i do it guys so it selects the apporpriate one correctly.

thanks for any help
Link to comment
https://forums.phpfreaks.com/topic/35240-drop-down-box-for-malefemale-gender/
Share on other sites

<?php
if($profile->Get_Gender() == 'male'){
  $male = ' selected ';
}else{
  $female = ' selected ';
}

<select name="sel_Gender" class="style15" id="sel_Gender">
  <option value="Male" <?=$male?>>Male</option>
  <option value="Female" <?=$female?>>Female</option>
</select>
slightly different than jesi's, but same concept:
[code]
<?php
if($profile->Get_Gender() == "male"){
$male = " selected";
}else{
$male = "";
}
if($profile->Get_Gender() == "female"){
$female = " selected";
}else{
$female = "";
}

echo "<select name=\"sel_Gender\" class=\"style15\" id=\"sel_Gender\">\n".
    "<option value=\"Male\"". $male .">Male</option>\n".
    "<option value=\"Female\"". $female .">Female</option>\n".
    "</select>\n";
?>
[/code]

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.