Dynamic drop down - How to Keep from duplicating entry?
Posted: Mon Mar 12, 2007 9:29 am
Hi there, this forum has been tremendously helpful for me...
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:
http://www.lovealotkennels.com/test2.php is where I am testing this, the drop down works and it searches properly, I just can't seem to figure out how to get it to not display "Yorkshire Terrier" a hundred times. Thanks for any suggestions!
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
?>