I am trying to query a MySQL table. I want to be able to have a list box with the column of "name" in the table "data". then select a single name from the list box and have it output the values in the other fields for that particular name.
I know how to create a query to out put the information and I know how to populate the list box. But am having trouble getting them tied together. Here is what I got. Any help would be greatly appreciated.
List box:
<?php
$sql = "select * from data";
$result = mysql_query($sql);
?>
<form>
<SELECT NAME="Select1" SIZE="1">
<option value="-1" selected="selected">All</option>
<?
while ($items = mysql_fetch_array($result))
{
?>
<OPTION VALUE="<? echo $items['Name'] ?>"><? echo $items['Name'] ?></OPTION>
<?
}
?>
</SELECT><BR>
Query:
$result = mysql_query("SELECT * FROM data ORDER BY Name ASC");
if(mysql_num_rows($result)) {
$color = "#D8DBFE";
while($row = mysql_fetch_row($result))
{
print("</tr><tr>");
if($color == "#D8DBFE") {
$color = "#A6ACFD";
} else {
$color = "#D8DBFE";
}
print("<td width=\"7%\" bgcolor=\"$color\"><left><small>");
print("<font face=\"Verdana\"><strong>$row[1]</strong></font></small></left></td>");
print("<td width=\"5%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[2]</font></small></center></td>");
print("<td width=\"5%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[3]</font></small></center></td>");
print("<td width=\"7%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[4]</font></small></center></td>");
print("<td width=\"5%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[5]</font></small></center></td>");
print("<td width=\"5%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[6]</font></small></center></td>");
print("<td width=\"5%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[7]</font></small></center></td>");
print("<td width=\"7%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[8]</font></small></center></td>");
print("<td width=\"5%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[9]</font></small></center></td>");
print("<td width=\"5%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[10]</font></small></center></td>");
print("<td width=\"5%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[11]</font></small></center></td>");
print("<td width=\"7%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[12]</font></small></center></td>");
print("<td width=\"5%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[13]</font></small></center></td>");
print("<td width=\"5%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[14]</font></small></center></td>");
print("<td width=\"5%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[15]</font></small></center></td>");
print("<td width=\"7%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[16]</font></small></center></td>");
print("<td width=\"5%\" bgcolor=\"$color\"><center><small>");
print("<font face=\"Verdana\">$row[17]</font></small></center></td>");
}
}
</script>