我想通过从 mysql 表中获取值来创建一个下拉区域。此代码似乎不起作用;它打印出来的只是没有内容的下拉框,我怎样才能让它工作?或者有没有其他程序可以做到这一点?
<?
$connection = mysql_connect("localhost", "root", "");
mysql_select_db("test", $connection);
$query = "SELECT full_name FROM test";
$names = mysql_query($query);
function dropDown($content, $result)
{
while($row = mysql_fetch_row($result))
{
$name = $row[0];
$content .= "<option value='$name'>$name</option>";
}
}
$content=<<<EOT
<html>
<body>
<select name="name">
EOT;
dropDown($content, $names)
$content.=<<<EOT
</select>
</body>
</html>
EOT;
echo $content;
?>