phpQuestioner Posted August 19, 2007 Share Posted August 19, 2007 I have a data table with a field that contains the exact same text (example "some text") on several different rows. How can I display all my rows without getting duplicates of this field; I only want to display this field once. I tried to use a LIMIT, but this is not what I needed. This code is for a drop down menu. Here is my current MySQL/PHP/HTML Code: <form> <select id="ajaxmenu" size="1"> <?php mysql_connect("localhost","username","password"); mysql_select_db("myVex"); $results = mysql_query("select make from myTable order by make asc"); while($r=mysql_fetch_array($results)) { $make=$r["make"]; echo "<option value=\"08-18-2007.php?make=Chevrolet\">$make</option>\n"; } ?> </select> <input type="button" onClick="ajaxcombo('ajaxmenu', 'contentarea')" value="Go"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/65731-solved-how-to-limit-a-database-field-to-displaying-only-one-time-and-still-display-all/ Share on other sites More sharing options...
trq Posted August 19, 2007 Share Posted August 19, 2007 SELECT DISTINCT make FROM myTable ORDER BY make ASC Quote Link to comment https://forums.phpfreaks.com/topic/65731-solved-how-to-limit-a-database-field-to-displaying-only-one-time-and-still-display-all/#findComment-328342 Share on other sites More sharing options...
phpQuestioner Posted August 19, 2007 Author Share Posted August 19, 2007 Thank You Thorpe - I Had Not Heard of "DISTINCT" before; but that did the trick. Thank You for telling me about MySQL DISTINCT. Quote Link to comment https://forums.phpfreaks.com/topic/65731-solved-how-to-limit-a-database-field-to-displaying-only-one-time-and-still-display-all/#findComment-328344 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.