[英]get value of the select box in a form
我尝试从选择框中获取选定的值,我用它来获取结果
$receiver=$_POST['receiver'];
但我一直得到0个结果吗?
<form method="post" action="new.php?send">
<label for="select">
<select name="receiver" value="Select" size="1">
<?php
$sql = "SELECT fullname FROM users";
$result = mysql_query($sql) or die (mysql_error());
while ($row = mysql_fetch_array($result))
{
$id=$row["id"];
$name=$row["fullname"];
$options .= '<option name="selected" value="'.$id.'">'.$name.'</option>';
}
echo $options; ?>
</option>
</select>
<input id="send" type="submit" name="Submit" value="Submit">
</form>
您的SQL错误。 您正在尝试打印ID,但未选择它。 另外,在select的结束标记之前没有必要的</option>
,这也可能会引起问题。
从用户中选择ID,全名
这样您就可以获取id并最后编写。不需要o
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.