I have managed to display the names from the database but what I want to be able to is show the location with the names underneath. All I am getting at the moment is the location with one name underneath. Just wondered what I might be doing wrong in my code.
For example in my database under location of brighton I have three names in there these are john, peter, shaun
brighton
john, peter, shaun
london
mark, shaun
milton keynes
andrew, matt, darren
Here is my code
$query = "SELECT location, name,
count(*) AS cnt
FROM friends_list GROUP BY location";
$res = mysql_query($query) or die(mysql_error());
if(mysql_num_rows($res) > 0) {
while($row=mysql_fetch_array($res)) { ?>
<font face=arial size=2><? echo $row['location']; ></a>
<br>
<? echo $row['names']; ?> (<? echo $row['cnt']; ?>)</font><<br>
<? }
}
else {
echo "Nothing found";
} ?>