[英]how to display mysql data using drop down?
here is what i came up, i could insert a data into my "gender" field, but when I'm in edit/update page, i want the "gender" field only displays "Select One" value, not "male/Female" 这就是我的想法,我可以在“性别”字段中插入数据,但是当我进入编辑/更新页面时,我希望“性别”字段仅显示“选择一个”值,而不是“男性/女性” ”
thanks in advance 提前致谢
<form action='#' method='post' border='0'>
<table>
<tr>
<td>
<select name="gender" id="gender">
<option>Select One</option>
<option>Male</option>
<option>Female</option>
</select>
</td>
</tr>
<td>
<input type='hidden' name='id_number' value='<? php echo $id_number ?>' />
<input type='hidden' name='action' value='edit' />
<input type='submit' value='Edit' />
</td>
</table>
</form>
您必须将一个名为selected="selected"
的属性添加到默认情况下要选择的<option>
标记中。
Simply import the $gender value from the db into the edit page and then add this : 只需将$ gender值从数据库导入到编辑页面,然后添加以下内容:
<select name="gender" id="gender">
<option>Select One</option>
<option <?if $gender=="Male" echo 'selected="selected"'?>>Male</option>
<option <?if $gender=="Female" echo 'selected="selected"'?>>Female</option>
</select>
Thats it friend.I hope it will useful for you much 就是朋友。我希望它对您有很大帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.