Topic awaiting preservation: cont different (Page 1 of 1) |
|
---|---|
Bipolar (III) Inmate From: |
posted 10-22-2005 21:58
oh what i have is a list of ip adresses and pages that they viseted in my a table but each page they visited is a seperate row so how can i count all the different ip adressess to determine unique visitors |
Bipolar (III) Inmate From: f(x) |
posted 10-22-2005 22:12 |
Maniac (V) Mad Scientist From: :morF |
posted 10-24-2005 06:45
If you're going to count like that, you should probably assign the result to something so it can be called up later on, so 'SELECT COUNT(DISTINCT('user_ip')) AS unique_ip FROM my_table' would be more appropriate I think |
Maniac (V) Inmate From: under the bed |
posted 10-24-2005 13:50
What is the advantage to doing it that way skaarjj? |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 10-24-2005 17:51
It just names the result. I think if you don't do it that way you end up with something like mysql_result_array['count'] or something like that. |
Maniac (V) Inmate From: under the bed |
posted 10-24-2005 21:33 |
Bipolar (III) Inmate From: f(x) |
posted 10-25-2005 00:04 |
Maniac (V) Mad Scientist From: :morF |
posted 10-25-2005 07:39
Which is perfectly valid. I usually, when i'm counting fields, always apply them to names with AS since when I'm doing it I end up doing multiple counts of interrelated fields (now we get into complex, multi-pathed SQL statements) so assigning them ot names helps to keep things clear. In a single count situation as this it's not necessary, it's just habit. |
Maniac (V) Inmate From: under the bed |
posted 10-25-2005 15:44
Thanks for clarification =) |
Paranoid (IV) Inmate From: [s]underwater[/s] under-snow in Juneau |
posted 10-25-2005 20:14
Another way to do this is to take each ip returned from " SELECT ip FROM site_info " and assign each item returned to an assosiative array with the name of the value returned. code: while ($row=mysql_fetch_array($result)){ foreach ($row as $key => $value){ $ip[$value]=$value; } }
|
Maniac (V) Mad Scientist From: :morF |
posted 10-26-2005 01:05
True, but whyp ut your server through the extra processing load when you can just get the SQL to count it all up for you? |
Maniac (V) Inmate From: under the bed |
posted 10-26-2005 01:44 |
Paranoid (IV) Inmate From: France |
posted 10-26-2005 01:52 |
Paranoid (IV) Inmate From: [s]underwater[/s] under-snow in Juneau |
posted 10-26-2005 06:24
quote:
|
Maniac (V) Inmate From: under the bed |
posted 10-26-2005 15:34 |