# Display data format?

**URL:** https://forum.kirupa.com/t/display-data-format/237996
**Category:** Uncategorized
**Created:** [September 6, 2007, 5:06am UTC](https://forum.kirupa.com/t/display-data-format/237996 "2007-09-06T05:06:01Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jasonhardwick](https://avatars.discourse-cdn.com/v4/letter/j/c68b51/32.png) [@jasonhardwick](https://forum.kirupa.com/u/jasonhardwick)
#### Post date: [September 6, 2007, 5:06am UTC](https://forum.kirupa.com/t/display-data-format/237996/1 "2007-09-06T05:06:01Z")

</div>

I have created a php file that pulls companies from mysql and orders them by city how can i list the city only once?

```php
            <?
$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
