I need to know how to keep a dynamicly generated (from mysql) drop down from repeating entries, when entries are repeated in the table. Here is my current code which is working fine:
Code: Select all
<?
$query="SELECT ptype FROM dogs";
/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */
$result = mysql_query ($query);
echo "<select name=q></option>";
// printing the list box select command
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[ptype]>$nt[ptype]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
?>