> I've run into a small bump in some code I'm writing for a membership > database. The first thing that needs to be done is an index of all > states in the US with members. The fun part is that the state > information is stored as the abbreviation in the database (ie MI, WI) > and the HTML page needs to display the full name of the State. I want to > display the information in a four column table that kicks out as many > rows as needed. Now in order to get the full name of the state, I'm > running the state result through a switch statement. Actaully, it's > working rather well expect for this little issue: > > Row 8: South Dakota Tennessee Texas Virgina > Row 9: West Virgina Wisconsin Texas Virgina > > I need to kill that extra Texas and Virgina.....here's how I'm doing this: > > <table border=1> > <? > $query=mysql_query("SELECT DISTINCT state FROM members WHERE > country='US' ORDER BY state ASC");
Try something more like this: <table> <tr> <?php // Assuming this ($statenames) is a full list // and that uppercase appreviations come from the DB // and that you implement error handling $statenames = array('WA' => 'Washington', 'OR' => 'Oregon'); $i = 1; $count = mysql_num_rows($query); while ($row = mysql_fetch_assoc($query)) { echo "\t<td>". $statenames[$row['state']] ."</td>\n"; if (($i % 4) === 0 && $count !== $i++) { echo "</tr>\n<tr>\n"; } } ?> </tr> </table> Regards, Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php