Count unique user clicks

Discussion in 'Programming' started by edhan, Dec 8, 2007.

  1. #1
    Hi

    Hope someone can advice on how am I to write a php code to track unique user count for every click.

    Thinking of creating a table about counting with the fields as id, count and clicked.

    ID - Article ID
    Count - Counting the number of clicks
    Clicked - Track userid from another table

    How am I to insert the userid from another table into the clicked field when the user clicks on count button? What I am saying is that a user has read an article and once finish reading, he will click on the count button to record as 1 count and his userid will be recorded in the clicked field.

    This clicked field will be checked again when another user click on the count button to ensure that it is not the same user. Once verify not the same user, it will record the userid in the clicked field.

    Example:

    ID Count Clicked
    01 2 21, 53
    02 5 5, 23, 49

    For ID - 01, it has 2 counts and Clicked by userid 21, 53. For ID - 02, it has 5 counts and clicked by userid 5,23, 49.

    Any help will be greatly appreciated.
     
    edhan, Dec 8, 2007 IP
  2. UnknownFury

    UnknownFury Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    To record userid or whatever have a session variable and insert that session variable into this table once they click the button.

    To check if its unique do a query looking for their userID and that documents ID. Then using mysql_num_rows see if it has 0 - if so then add one to the count and record userID etc.
     
    UnknownFury, Dec 9, 2007 IP
  3. edhan

    edhan Active Member

    Messages:
    364
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Sorry if this sounds dumb as I don't really know how, can you give an example?

    Thanks!
     
    edhan, Dec 9, 2007 IP
  4. mrobert

    mrobert Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You could save the IP address of the user in a separate row, and check against that when adding a new user, to make sure clicks are unique.
     
    mrobert, Dec 10, 2007 IP
  5. edhan

    edhan Active Member

    Messages:
    364
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #5
    My problem is that I do not know how to write the program to add the ip address in the IP Field and check for unique click. Also, how to program it to write a new IP address in the same IP Field for the same article ID. I am really lost how to do it.
     
    edhan, Dec 10, 2007 IP