Counting last 15 visits to the site

Discussion in 'Databases' started by devo10, Aug 25, 2010.

  1. #1
    Hello all

    I want to keep track of the ‘last 15' times a user has visited my site. I have created a table with the following fields:

    count username timestamp

    I have set count to autoincriment, but it obviously counts every user so that an individual user won’t have 1,2,3, but could have 1,6,19 etc.

    After they have had their last 15 visits counted I want the oldest one to be deleted so that there is only ever 15 records for any individual user at any one time.

    Any ideas on how to do this?

    Many thanks in advance
     
    devo10, Aug 25, 2010 IP
  2. Mohie

    Mohie Peon

    Messages:
    122
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I suggest u to do this,
    create a table with the following fields,
    vid,username,time
    with vid auto inc

    when ever some one log in , an insert query , saves that into ur table..

    when u want to review the last 15 visits of a specific user, simply do query: SELECT * FROM ur_table WHERE username='user' order by vid desc limit 15


    and of course then u fetch that query
    and u printout the time

    regards,
    any help am ready :)
     
    Mohie, Aug 25, 2010 IP
  3. devo10

    devo10 Active Member

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #3
    Thanks very much Mohie

    I'm going to give it a try and I'll get back to you to let you know if it was successful

    Cheers
     
    devo10, Aug 25, 2010 IP