Am attemtping to populate a dropdown menu with the results of my SQL query. The script functions, however I just am unsure of the syntax to add the results into the html dropdown menu. Currently it populates a table with the results. Here is my code:
<?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);
?>