I’ve built a php/mysql -based dynamic dropdown menu with the following code:
<SELECT>
<?
@ $db = mysql_connect("localhost", "smth", "smth");
mysql_select_db("database_name");
$strSQL = "SELECT * FROM select1options ORDER BY name";
$rs = mysql_query($strSQL);
$nr = mysql_num_rows($rs);
for ($i=0; $i<$nr; $i++) {
$r = mysql_fetch_array($rs);
echo "<OPTION VALUE=\\"".$r["name"]."\\">".$r["name"]."</OPTION>";
}
?>
</SELECT>
However, the problem is that it returns all the records in the option tags.
For example if I’m building a dropdown menu on country, and there are three recordwith “USA” in the country field, it returns three options with the value of “USA”. I only want it to return one for each unique value in the table.
How do I do that?