3,423
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
</head>
<body>
<?php
$dbsock=mysql_connect("localhost","root","123456");
mysql_select_db("radius",$dbsock);
$sql="select name from scity;";
$res=mysql_query($sql);
echo"<form>";
echo"<select>";
while($array=mysql_fetch_array($res))
{
echo "<option value=" . $array['name'] . ">" . $array['name'] . "</option>";
}
echo"</select>";
echo"</form>";
?>
</body>
</html>
mysql> use radius;
Database changed
mysql> select name from scity;
+-----------+
| name |
+-----------+
| Lily |
| Jim |
| HanMeimei |
| Lilei |
+-----------+
4 rows in set (0.00 sec)
while($array=mysql_fetch_array($res))
{
echo "<option value=" . $array['name'] . ">" . $array['name'] . "</option>";
}