Jump to content

[SOLVED] Statistics from mysql


graham23s

Recommended Posts

Hi Guys,

 

when people register on my website they are from different countries etc, i was wondering if there was a way to display statistics e.g "14 users from united states"

 

i know how to do mysql_num_rows for the total users but i was wondering what the query would be for specific information.

 

thanks for nay help

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/50261-solved-statistics-from-mysql/
Share on other sites

it would be something like this

 

SELECT country, count(*) as Total Group By country

 

the 2 field you pull will be

Total  = number of entrys per country

country = the counter

 

your get a row per country

 

 

 

as a note i am drained and didn't test the above,

 

Hi Guys,

 

i have this so far (i know it's wrong lol)

 

     $query = "SELECT country, count(*) as Total FROM membership Group By United States";
     $result = mysql_query($query) or die (mysql_error());

 

when you say "country" do you mean the actual country name or the row in my membership table called country?

 

also how would i echo out the rows at all?

 

thanks for the help guys

 

Graham

$query = "SELECT country, count(*) as Total FROM membership Group By country";
$result = mysql_query($query) or die (mysql_error());

while (list ($country, $total) = mysql_fetch_row($result)) {

       echo "$country : $total <br>";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.