我创建了以下代码,它使下拉列表能够从 sql db 中获取所有值,它能够获取数字但不显示..
<?php
$link = mysql_connect('www.xxxxxxxx.com', 'xxxxxxx', 'xxxxxxx');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xxxxxxxxxxxxxxxxxxxxx", $link);
function print_dropdown($query)
{
$queried = mysql_query($query);
$menu = '<select name="Topic">';
while ($result = mysql_fetch_array($queried)) {
$menu .= '
<option value="' . $result['topic'] .'</option>';
}
$menu .= '</select>';
return $menu;
}
echo print_dropdown("SELECT topic FROM learning_outcome");
?>
但输出似乎是空的.. :(