jonnyw6969 Posted December 21, 2007 Share Posted December 21, 2007 Hi there, Could someone please help me im completely stuck and not even sure if what im trying to do can be done. Ok first off im trying to code a sessioned visitor counter for my website. That bit hasnt been a problem. Ive created a simple table with 2 feilds. 1) count_id 2) count And that seems to work great, just adding 1 everytime someone new visits. What i want to do and what seems to have worked well is add a date columb to the table. When someone visits my site on a new day it creates another row with the new date and then adds 1 to the count of the new date. This now gives me daily stats. I have a admin panel to my website which show me these stats. This is where the problem occurs. I can show the stats of the present day ok but i want to show how many people have visited in the last 7 days. Im assumming i need to add together the count column of the last 7 rows. This is where i need help. Please someone help Regards Jon Quote Link to comment https://forums.phpfreaks.com/topic/82679-visitor-counter-and-adding-together-column-data/ Share on other sites More sharing options...
chigley Posted December 21, 2007 Share Posted December 21, 2007 Just to clarify, as you've contradicted yourself. Is there a row per visit? Or a row per day? Quote Link to comment https://forums.phpfreaks.com/topic/82679-visitor-counter-and-adding-together-column-data/#findComment-420501 Share on other sites More sharing options...
jonnyw6969 Posted December 21, 2007 Author Share Posted December 21, 2007 Hi A row per day. Sorry Jon Quote Link to comment https://forums.phpfreaks.com/topic/82679-visitor-counter-and-adding-together-column-data/#findComment-420502 Share on other sites More sharing options...
chigley Posted December 21, 2007 Share Posted December 21, 2007 <?php $query = mysql_query("SELECT SUM(count) FROM table ORDER BY date DESC LIMIT 7") or die(mysql_error()); list($visits) = mysql_fetch_row($query); echo "{$visits} visits in the last week."; ?> I'm not sure if I ordered the date field the right way round. I think I got it right though - give it a go Quote Link to comment https://forums.phpfreaks.com/topic/82679-visitor-counter-and-adding-together-column-data/#findComment-420509 Share on other sites More sharing options...
jonnyw6969 Posted December 21, 2007 Author Share Posted December 21, 2007 Hi chigley I'll give it a go now Many many thanks Jon Quote Link to comment https://forums.phpfreaks.com/topic/82679-visitor-counter-and-adding-together-column-data/#findComment-420513 Share on other sites More sharing options...
jonnyw6969 Posted December 21, 2007 Author Share Posted December 21, 2007 Hi Works like a dream. Many many thanks Have a good Xmas Jon Quote Link to comment https://forums.phpfreaks.com/topic/82679-visitor-counter-and-adding-together-column-data/#findComment-420547 Share on other sites More sharing options...
chigley Posted December 21, 2007 Share Posted December 21, 2007 No worries, merry Xmas! Quote Link to comment https://forums.phpfreaks.com/topic/82679-visitor-counter-and-adding-together-column-data/#findComment-420548 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.