Jump to content

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>";
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.