im tryin to get the selected value from select box i used this to get the result
$receiver=$_POST['receiver'];
but i keep getting the result 0 anyone ?
<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>
Your SQL is wrong. You are trying to print the ID, but you are not selecting it. Also, there is an unneeded </option>
right before the closing tag of your select - that might cause problems too.
select id,fullname from users
so that you can fetch id and in last you are writing .no need o
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.