I have read plenty of ways of removing the comma at the end of a string when doing basic queries but none of the basic stuff seems to be working with this particular script. Hopefully I'm just over thinking this. My script goes through the database and places the cities under the proper states but I need the last cities comma to be removed.
Here is the script I am using
<?php
$sql = "SELECT * FROM markets WHERE id = 0 ORDER BY market_state";
$res = mysql_query($sql);
$list = array();
while ($r = mysql_fetch_object($res)) {
$list[$r->market_state][$r->id]['market_cities'] = $r->market_cities;
}
foreach ($list as $market_state => $market_cities) {
echo '<h1>' . $market_state . '</h1>';
foreach ($market_cities as $cityId => $cityInfo) {
echo $cityInfo['market_cities']. ',';
// etc
}
}
?>