How to load data on option box in php
- by user225269
I'm having trouble loading the mysql data on the html form option box using php. Here's my code:
<?php
$con = mysql_connect("localhost","myuname","mypassword");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("school", $con);
$idnum= mysql_real_escape_string($_POST['idnum']);
$result = mysql_query("SELECT * FROM student WHERE IDNO='$idnum'");
?>
<?php while ( $row = mysql_fetch_array($result) ) { ?>
<tr>
<td width="30" height="35"><font size="2">*I D Number:</td>
<td width="30"><input name="idnum" type="text" maxlength="5" value="<?php echo $row["IDNO"]; ?>" readonly="readonly"></td>
</tr>
My problem is loading it here:
<td><font size="2">Gender</td>
<td>
<select name="gender" id="gender">
<font size="2">
<option value="<?php echo $line['IDNO']; ?> "><?php $line['GENDER'] ; ?></option>
</select></td></td>
The table looks like this:
IDNO | GENDER
123 | M
321 | F
What am I supposed to do?To load the exact gender corresponding to the IDNO?