在此代码中,我在下拉列表中获取值,但是当我在下拉列表中选择数据时,它不显示所选值,它在第 66 行显示未定义的索引类别。所以请帮助我。
<form name="choose" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
$host="localhost";
$username="root";
$password="";
$db_name="slseatapp";
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select db");
$query="SELECT id,course_code FROM `coursemaster` ORDER BY `coursemaster`.`id`";
$result = mysql_query($query);
?>
<select name=category>
<?php
while($nt=mysql_fetch_array($result)) {
echo "<option value='".$nt['course_code']."'>".$nt['course_code']." </option>";
}
?>
</select>
<input type="submit" name="submit" value="save category" />
</form>
<?php
if($_GET){
echo 'The course_code selected is'.$_POST['category'];
}
?>