Jump to content

Most Viewed List


TheFilmGod

Recommended Posts

How would I use mysql to fetch data from a table and list the top 10 watched movies. The database is "TheFilmGod" and uses "views" as the column for the number of views. Then php would output the top ten watched videos by sending out the page ids. So each row would have "views" and a "page_id" column.

 

So I want the mysql to search and find the top 10 largest numbers in the "views" column send back the "page_id" back. I'm totally confused. Any help on any of the steps is greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/44711-most-viewed-list/
Share on other sites

First of all you need the name of the table and not the database.. the database name is only relevant for connecting to the database and since you already have records in your db you must have made a db connection - so I'll call you table for table :)

 

"SELECT page_id FROM table ORDER BY views DESC LIMIT 10"

 

The above query will sort your table by views in DESCADING order, which means the largest number first, and then select the page_id from the first 10 records in the newly sorted/ordered tabel.

 

 

Link to comment
https://forums.phpfreaks.com/topic/44711-most-viewed-list/#findComment-217097
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.