This code stops duplicates appearing in your dropdown boxes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?php include('cmdataconn.inc'); $result = mysql_query("SELECT * FROM targets order by client limit 10"); while($row = mysql_fetch_array($result)) { echo "<select name='tag[]' class='options'>"; $sql = "SELECT tagname FROM tags order by tagname"; // new options mysql $resulta = mysql_query($sql); echo "<option value='" . $row['tagname'] ."'>" . $row['tagname'] ."</option>"; //or put whats in the database in select options while ($rowa = mysql_fetch_array($resulta)) { //prevents dupes in dropdown $tagname= $rowa['tagname'];// get all results if($tagname != $row['tagname']){ //filter results // end of prevent dupes echo "<option value=\"$tagname\">$tagname</option>"; //output filtered results } //end while } //end while echo "</select>"; } ?> |