我有名为的表,coursemaster
它有 3 列:和. 我想从 mysql 获取下拉列表中的值,但它在下拉列表中不可见,我想选择该值。id
course_code
course_name
course_code
<?php
$host="localhost";
$username="root";
$password="";
$db_name="slseatapp";
$tbl_name="coursemaster";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name ORDER BY id ASC";
$result=mysql_query($sql);
if ($result === false) { echo "An error occurred."; }
?>
<html>
<head>
<title>Your title here</title>
</head>
<body>
<select name="usrname" id="usrname">
<option>Select employ</option>
<?php
while($rows=mysql_fetch_array($result)){
?>
<option value="<? echo $rows['id']; ?>"><? echo $rows['course_code']; ?></option>
<?php
}
mysql_close();
?>
</select>
</body>
</html>