Ouch... Ok, so you want:
user_id int
date_created timestamp
Then the SQL you use will be:
insert into [table] values([user_id],now());
select * from [table] where user_id=[user_id] order by date_created desc limit 15;
This will give you the last 15 records. No need to store the actual count, since each record can be summed to determine the count (or when you iterate through the record set)
Quote:
Originally Posted by pedagog
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 autoincrument, 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
|