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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.