First of all, thanks so far. But the problem with the code you wrote was that if there were no listings found in the databse for Colorado, for example, it would not print "Colorado". So that is what I am trying to solve now. Read on๐
I added some things to your code to try to make it work better but I know it isn't there yet. The "state" values are in the form of "nv" for Nevada, for example, so I need to run that long "if ("ny" == $state) $VLocation = "New York";" series so that the state's description or $VLocation prints to the page while I need the database's stored short version("nv") to pass the URL variable in the link for each state.
Now we have come to the point. I need all the different locations you see in the code below to be displayed whether or not there was an entry in the database that matched the particular location.
p.s. I bolded the code I added below
Thanks again and again.
<?
//there are results so
echo "<table><tr>"; //start the table
$i=1; //initliaze a counter
while ($rows=mysql_fetch_array($result)){
//assign the data to some variables - not really needed but clearer when coding
$state=$rows['State'];
$count=$rows['Count'];
//Figure out state's full name or description
$state = strtolower($state);
//spell out location
if ("al" == $state) $VLocation = "Alabama";
else if ("ak" == $state) $VLocation = "Alaska";
else if ("az" == $state) $VLocation = "Arizona";
else if ("ar" == $state) $VLocation = "Arkansas";
else if ("ca" == $state) $VLocation = "California";
else if ("co" == $state) $VLocation = "Colorado";
else if ("ct" == $state) $VLocation = "Connecticut";
else if ("de" == $state) $VLocation = "Delaware";
else if ("fl" == $state) $VLocation = "Florida";
else if ("ga" == $state) $VLocation = "Georgia";
else if ("hi" == $state) $VLocation = "Hawaii";
else if ("id" == $state) $VLocation = "Idaho";
else if ("il" == $state) $VLocation = "Illinois";
else if ("in" == $state) $VLocation = "Indiana";
else if ("ia" == $state) $VLocation = "Iowa";
else if ("ks" == $state) $VLocation = "Kansas";
else if ("ky" == $state) $VLocation = "Kentucky";
else if ("la" == $state) $VLocation = "Louisiana";
else if ("me" == $state) $VLocation = "Maine";
else if ("md" == $state) $VLocation = "Maryland";
else if ("ma" == $state) $VLocation = "Massachusetts";
else if ("mi" == $state) $VLocation = "Michigan";
else if ("mn" == $state) $VLocation = "Minnesota";
else if ("ms" == $state) $VLocation = "Mississippi";
else if ("mo" == $state) $VLocation = "Missouri";
else if ("mt" == $state) $VLocation = "Montana";
else if ("ne" == $state) $VLocation = "Nebraska";
else if ("nv" == $state) $VLocation = "Nevada";
else if ("nh" == $state) $VLocation = "New Hampshire";
else if ("nj" == $state) $VLocation = "New Jersey";
else if ("nm" == $state) $VLocation = "New Mexico";
else if ("ny" == $state) $VLocation = "New York";
else if ("nc" == $state) $VLocation = "North Carolina";
else if ("nd" == $state) $VLocation = "North Dakota";
else if ("oh" == $state) $VLocation = "Ohio";
else if ("ok" == $state) $VLocation = "Oklahoma";
else if ("or" == $state) $VLocation = "Oregon";
else if ("pa" == $state) $VLocation = "Pennsylvania";
else if ("ri" == $state) $VLocation = "Rhode Island";
else if ("sc" == $state) $VLocation = "South Carolina";
else if ("sd" == $state) $VLocation = "South Dakota";
else if ("tn" == $state) $VLocation = "Tennessee";
else if ("tx" == $state) $VLocation = "Texas";
else if ("ut" == $state) $VLocation = "Utah";
else if ("vt" == $state) $VLocation = "Vermont";
else if ("va" == $state) $VLocation = "Virginia";
else if ("wa" == $state) $VLocation = "Washington";
else if ("wv" == $state) $VLocation = "West Virginia";
else if ("wi" == $state) $VLocation = "Wisconsin";
else if ("wy" == $state) $VLocation = "Wyoming";
else if ("dc" == $state) $VLocation = "District of Columbia";
else if ("australia" == $state) $VLocation = "Australia";
else if ("england" == $state) $VLocation = "England";
else if ("canada" == $state) $VLocation = "Canada";
else if ("other" == $state) $VLocation = "Other Countries";
else $VLocation = "";
if($count!=0){
[B]echo "<a href='listings.php?companytype=ta&state=$state'>$VLocation</a><br>";[/B]
} else {
echo "$state<br>";
} //close if / then loop
if ($i==13){ //start next column
echo "</td><td>;
} //close if/then loop
$i++; //increment the counter
} //close the while loop
echo "</tr></table>";
} //close the main if/then loop
?>