SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Jan 2001
    Posts
    244
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Count hits to record on DB

    Hello I'm designing a news system for my website using php/mysql and I want to know which news are read the most.
    I created a field in the DB called "hits". Every time the news is read I want that field from that record being viewed get increased by one. I already have the query for displaying the news on the page working fine, but I need the other query for update the hits count on the DB every time the record is viewed.
    Any help would be appreciated.
    Guillermo

  2. #2
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After calling the record, use the query,

    sql = "UPDATE newstable SET hits=hits+1";

  3. #3
    SitePoint Addict
    Join Date
    Jan 2001
    Posts
    244
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks.. I'll try it.
    And what type should that field be? Would "INT" be ok?
    Guillermo

  4. #4
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yip


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
  •