Jump to content

[SOLVED] List ONLY the USA States in a query


Presto-X

Recommended Posts

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.