1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to sort my articles/content by Facebook Likes?

Discussion in 'PHP & Perl' started by billyd, Jan 17, 2012.

  1. billyd

    billyd Regular Member

    Joined:
    Jun 1, 2010
    Messages:
    223
    Likes Received:
    17
    I have a site with articles/content that displays 4 per page. Each article has a Facebook Like button associated with it. How can I sort the page (I have PHP/MySQL) based on the number of Likes it has?
     
  2. BlueZero

    BlueZero Power Member

    Joined:
    Jul 6, 2011
    Messages:
    500
    Likes Received:
    257
    Occupation:
    Webdeveloper, Project Manager
    Location:
    Byte in the Net
    Home Page:
    I think that you cant do it with php mysql. Unless you have stored the number of likes in your database. But i doubt it.

    You should be able to do it with javascript.
    Or you can parse the page with javascript and store the numbers in mysql and then nextime the page appears you can sort it with php/mysql.

    Only problem would be if you have paging. Then you are screwed :).

    The best option would be using facebook API to get the numbers.
     
  3. billyd

    billyd Regular Member

    Joined:
    Jun 1, 2010
    Messages:
    223
    Likes Received:
    17
    Is it possible to do with views (I keep track of the views in my sql db)