SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist Tecknowjnkie's Avatar
    Join Date
    Nov 2004
    Location
    Mission Viejo
    Posts
    403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Articles displayed by times viewed

    I am hoping someone can point me to the tutorial or the section in one of the Sitepoint PHP Books ( i have them all but can 't locate the section) wherein it outlines how to create a little script that pulls say the top five most viewed articles for display. I remember seeing it somewhere, LOL

    Thank you all very much. :-)

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Location
    Beautiful Rhode Island, USA
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't point you to any book parts, but you'll want to use ORDER BY and LIMIT in your query:

    SELECT * FROM `table_name` WHERE some condition ORDER BY `times_viewed` LIMIT 0, 5;

  3. #3
    SitePoint Evangelist Tecknowjnkie's Avatar
    Join Date
    Nov 2004
    Location
    Mission Viejo
    Posts
    403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The sentece is easy, its the part that makes it add a +1 to the integer in the column viewed and all that @#$%^ stuff that I can not spit out on my own. :'(

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Location
    Beautiful Rhode Island, USA
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, gotcha. Hopefully someone else can point you to the info you're looking for. Sorry!

    However, just today there was a thread about incrementing a field by one:

    PHP Code:
    $sql "UPDATE `table_name` SET `times_viewed` = `times_viewed`+1 WHERE something"
    $query mysql_query($sql) or die(mysql_error()); 
    Maybe that will help you in the right direction.

  5. #5
    SitePoint Evangelist Tecknowjnkie's Avatar
    Join Date
    Nov 2004
    Location
    Mission Viejo
    Posts
    403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This definitely helps Bill, Thank you.

    It was a blurb in one of the books and I can not find it. It's killing me. It was so easy.
    If any one has done this please link me to the tutorial and or page #.

    TY again Bill


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •