Counting last 15 visits to the site - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Databases - MySQL, SQL, Oracle, Access and others

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-25-2010, 05:00 AM   #1 (permalink)
Junior Member
 
Join Date: Apr 2010
Posts: 8
Default Counting last 15 visits to the site

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
pedagog is offline   Reply With Quote
Sponsored Links
Old 09-11-2010, 09:18 PM   #2 (permalink)
Junior Member
 
Join Date: Sep 2010
Posts: 13
Default Re: Counting last 15 visits to the site

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 View Post
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
hothand is offline   Reply With Quote
Old 09-16-2010, 11:54 PM   #3 (permalink)
Junior Member
 
Join Date: Sep 2010
Posts: 39
Default Re: Counting last 15 visits to the site

there are many online websites available to keep a track of working and incoming of the visitors
asbharmal is offline   Reply With Quote
Old 10-05-2010, 07:56 AM   #4 (permalink)
Junior Member
 
Join Date: Jan 2010
Posts: 11
Default Re: Counting last 15 visits to the site

Yes.hothand is right. His query is perfect. It will bring you last 15 records from database.
giteshtrivedi is offline   Reply With Quote
Old 10-10-2010, 10:38 PM   #5 (permalink)
Junior Member
 
Join Date: Jul 2010
Location: http://www.hongkongseo.org/
Posts: 21
Default Re: Counting last 15 visits to the site

thanks for share
softwaretailor is offline   Reply With Quote
Reply

Tags
autoincriment

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 07:52 AM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting