Presto-X Posted April 9, 2007 Share Posted April 9, 2007 Hello guys, I could really use your help. I want to show a list of states at the top of a page, but I only want to show the ones that I have in my database. For example if there where only two states lets say Oregon and Idaho then the other 48 states would not show. $querystate=("SELECT state FROM `joomla_dealers`") or die(@mysql_error()); $resultstate=mysql_query($querystate); $numstate=mysql_numrows($resultstate); mysql_close(); $i=0; while ($i < $numstate) { $states=mysql_result($resultstate,$i,"state"); echo "<b><a href=\"index.php?state=$states\">$states</a></b> | "; $i++; } I have 2 links for Oregon and 1 for Idaho right now so when this loop runs it looks like this ID | OR | OR | the problem is that I only want the state to show up once how do I set my while loop to only echo out an item once? Quote Link to comment Share on other sites More sharing options...
btherl Posted April 9, 2007 Share Posted April 9, 2007 You can do: $querystate=("SELECT DISTINCT state FROM `joomla_dealers`") or die(@mysql_error()); Quote Link to comment Share on other sites More sharing options...
Presto-X Posted April 9, 2007 Author Share Posted April 9, 2007 that did the trick, thank you so much btherl for your help Quote Link to comment 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.