0

I have a table with the following values:

name_table

ID  Name  
1   Bob  
2   James  
3   Bob  
4   Joe

I am trying to do a search where it will give me the list names and how many times the name was found. What I am looking for is a result like this:

Bob 2  James 1  Joe 1  

The code:

(connection info)  
$query = "SELECT name, count(*) FROM name_table GROUP BY name;  
$result = mysqli_query($connection, $query) or die (Could not execute query"); 
while ($row = mysqli_fetch_assoc ($result)) 
echo ("$row['name']");  

It is showing me the names but not the count.

1 Answers1

0
$query="SELECT name, count(name) FROM name_table GROUP BY name ORDER BY name ASC;  
Osama
  • 2,912
  • 1
  • 12
  • 15