Jump to content

hits


brown2005

Recommended Posts

hits_user              

hits_user_type              

hits_date            

hits_count        

 

I have that table and

 

$sql = "SELECT year(hits_date) AS hits_year, COUNT(*) AS hits_unique, SUM(hits_count) AS hits_count

         FROM z_hits

       GROUP BY year(hits_date)

ORDER BY year(hits_date) DESC;";

 

which works fine and lists the years with the hits and unique hits, but obviously its not the fully unique hits because it is just counting the rows, so you could have two of the same user in the table, so how would i get around this?

 

thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/41173-hits/
Share on other sites

If you want to show the hits by a specific user, just add to your query:

 

<?php

$sql = "SELECT year(hits_date) AS hits_year, COUNT(*) AS hits_unique, SUM(hits_count) AS hits_count
FROM z_hits
WHERE hits_user = 'username'
GROUP BY year(hits_date)
ORDER BY year(hits_date) DESC;";

?>

 

If that is not what you are looking for, I don't understand your question.

Link to comment
https://forums.phpfreaks.com/topic/41173-hits/#findComment-199466
Share on other sites

sorry let me explain a bit more,

 

i want to show

 

year

hits

unique

 

 

i use

 

year - year(hits_date) AS hits_year

hits - SUM(hits_count) AS hits_count

unique - COUNT(*) AS hits_unique

 

but obviously the COUNT(*) is countin all the rows, and giving 88 unique users when there is less because some people have visited the site, more than once on different days...

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/41173-hits/#findComment-199474
Share on other sites

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.