开发者

list of allowed drop down/select values

The issue is i am selecting option 1 and then going to the next page and i am coming back.The option MALE is being saved.When i try to echo it,nothing is showing up.

<tr>
 <td class="tdvisitbig">
  <select class="selectbig" name="gender">
   <?
   $arr = array("1"=>"MALE", "2"=>"FEMALE");
   foreach($arr as $p=>$v)
   {
    if($p != $gender)
    {
     echo "<option value='$p'>$v</option>";
    }
    else
    {
     echo "<option selected value='$p'>$v</option>";
    }
   }
   ?>
  </select>
 </td>
</tr>

The code which i am using to echo it is

 if($gender == '1'){echo "male";}
 if($gender =开发者_开发百科= '2'){echo "female";}

Is there something i am missing .when i am selecting option 2 and save it and then try to echo it it prints out fine.

Thanks in advance.


Try

==

in the if condition..


According to your echo code, it should echo malefemale every time because you're using = instead of ==.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜