How to Display Most Popular Posts from Number of Views - Newbie Question

Discussion in 'PHP' started by misohoni, Dec 13, 2011.

  1. #1
    This isn't related to wordpress, but I'd like to access the DB and my setup is:

    log_downloads table, inside is video_id column and each has the recorded id of each video downloaded.

    What php do I use to display the most popular videos from the site?

    Cheers
     
    misohoni, Dec 13, 2011 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    LOL you need a custom writen script that can do that for you, there isn't a 'script' that figures that out for you! :)

    If you like to develop it yourselve, please tell us more about your tables and fields (mysql)
     
    EricBruggema, Dec 14, 2011 IP
  3. ekaddu

    ekaddu Active Member

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #3
    you should have made a video table and inside that table should stored no. of downloads. fetching most viewed from download table is not easy. probably you have to search the whole no. of videos agaisnt views.
     
    ekaddu, Dec 14, 2011 IP
  4. proactiv3

    proactiv3 Peon

    Messages:
    55
    Likes Received:
    7
    Best Answers:
    4
    Trophy Points:
    0
    #4
    If I understood correctly you have a table where you register each download. The video_id is a foreign key of another table (containing the video information). If so something like this should do the trick:

    SELECT video_id, COUNT(*) AS num FROM log_download GROUP BY video_id ORDER BY COUNT(*) DESC
    Code (markup):
     
    proactiv3, Dec 14, 2011 IP