brooksh Posted May 9, 2007 Share Posted May 9, 2007 I've been searching to figure out how not to have duplicates in a dropdown menu populated from my database. This is what I have, but how do I change it to get rid of duplicates? <?php $result = mysql_query("SELECT City FROM residential order by City"); echo "<select MULTIPLE NAME=\"City_code\">"; while($row = mysql_fetch_array($result)){ echo "<option name=\"City\" value=\"$row[City]\">$row[City]</option>"; } ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/50596-solved-poplulate-dropdown-menu-without-duplicates/ Share on other sites More sharing options...
trq Posted May 9, 2007 Share Posted May 9, 2007 $result = mysql_query("SELECT DISTINCT City FROM residential order by City"); Quote Link to comment https://forums.phpfreaks.com/topic/50596-solved-poplulate-dropdown-menu-without-duplicates/#findComment-248715 Share on other sites More sharing options...
brooksh Posted May 9, 2007 Author Share Posted May 9, 2007 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/50596-solved-poplulate-dropdown-menu-without-duplicates/#findComment-248718 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.