我試圖用我的SQL查詢結果填充下拉菜單。腳本函數,但是我只是不確定將結果添加到html下拉菜單中的語法。目前它使用結果填充表格。這裏是我的代碼:將值添加到MySql_Fetch_Array的下拉菜單框
<?php require_once('Connections/database.php'); ?>
<?php
$q=$_GET["q"];
mysql_select_db($database_db, $database);
$sql="SELECT cat_id, catname FROM categories WHERE cat_id = '".$q."'";
$result = mysql_query($sql);
echo "<table border='1'>
<tr>
<th>Category Name</th>
<th>Category ID</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['catname'] . "</td>";
echo "<td>" . $row['cat_id'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($database);
?>
你應該接受你 – 2010-10-13 15:34:49