I have created a php file that pulls companies from mysql and orders them by city how can i list the city only once?
<?
$DBhost = "$DBhost";
$DBuser = "$DBuser";
$DBpass = "$DBpass";
$DBName = "$DBName";
$table = "$table";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sql = "SELECT *
FROM $table
ORDER BY city
ASC, name";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
echo "<TABLE align=\"left\" cellspacing=\"0\" cellpadding=\"0\">";
while ($row = mysql_fetch_assoc($result)) {
echo "<TR>";
echo "<TD align=\"left\" valign=\"top\" <span class=\"style1\">".$row["city"];
echo "<br>";
echo "<align=\"left\" valign=\"top\" <span class=\"style1\">","<blockquote>".$row["name"];
echo "</blockquote>","</td>";
echo "</TR>";
}
echo "</TABLE>";
mysql_free_result($result);
?>
this is how it is currently displayed
Athens
—Gallery Fake
Boston
—KLUJ
Boston
—XYW
Rome
—SDE
This is how it should look
Athens
—Gallery Fake
Boston
—KLUJ
—XYW
Rome
—SDE