Jump to content

[SOLVED] Displaying The 10 Most Viewed Pages


suttercain

Recommended Posts

Hi everyone,

 

I built a page view counter that collects the page id (comicId) and the user's IP addresss so it doesn't get counter twice.

 

I would now like to display the top 10 most viewed pages. I need to get a total count of every time the comicId appears in the table and display the ten highest totals.

 

I tried using

 

<?php $tabsOne = mysql_query("SELECT *, COUNT(*) FROM comicCounter GROUP BY comicId LIMIT 0, 10") or die(mysql_error()); ?>

 

But I don't think this is the right path. Any ideas?

 

Thanks.

 

SC

No problemo

 

TABLE comicCounter

 

comicId    |      ipAddress    |    comicCounterId

4454        | 111.111.111.21  |              1

6767        | 111.111.111.21  |              2

7878        | 111.111.111.21  |              3

4454        | 421.121.121.21  |              4

 

That is the basic set up, times 1000's of records. But with this set up I would need 4454 to be counted as 2 and  6767 as 1 and 7878 as 1. Then I would need to display 4454 since it had two views and therefore is the most popular.

 

SC

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.