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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.