I am trying to put together a simple dropdown list from the MySQL table but all I can figure out how to get is one field listed in the dropdown. Any help would be apprectiated. Here is what I have so far:
<?
$db_name = "databse";
$table_name = "category";
$connection = @mysql_connect("localhost", "user", "secret") or die("Bummer - couldn't connect.");
$db = @mysql_select_db($db_name, $connection) or die("Rats - couldn't select database.");
$sql_select = "select cat_id, cat_name from category order by cat_id";
$result = @($sql_select, $connection) or die("Shucks - couldn't execute query.");
?>
Then in the form:
<td>
<select name="cat_id">
<?
while ( $row = mysql_fetch_row($result) )
echo "<option>".$row[0]."</option>\n" ;
?>
</select>
</td>
This populates the dropdown just fine but I can't figure out how to get the cat_name to show up with the cat_id. If I could get the cat_name to show without the cat_id but have the value of the cat_id as the result it would be the best... but not an issue.