onlyican Posted November 24, 2006 Share Posted November 24, 2006 Hey guysI have a small problemWhat I want to do is Record movement on my websiteFor exampleWhen a user clicks on the website I want to logWhat time they came on the websiteWhat page they are onThere IPWhere they come fromBut for every user, every pageso I can see that a user clicked on 10 pages before closing or somethingI was thinking of adding into a MySQL tableBut then if you look at a basic screen of 100 Unique Hits a daysay 3000 Page HitsThats a lot of data to add into a table thats 21000 entries per weekOR90000 entries on a 30 day monthSo what is the best way of storing all this data without killing the server by filling up a MySQL table Quote Link to comment Share on other sites More sharing options...
marcus Posted November 24, 2006 Share Posted November 24, 2006 Create a table, and log the users IP.Insert their IP into the table, and have something like:IP | Hits | Time | LastPageAnd check if the user's IP already exists in the database, and if it does then it won't create a new row each time. Then just do[code]$sql = "SELECT ip FROM stats WHERE ip ='$_SERVER[REMOTE_ADDR]'";$res = mysql_query($sql);$res2 = mysql_fetch_assoc($res);$num = mysql_numrows($res);if($num > 0){//update stats}else {$sql = "INSERT INTO stats (`ip`) VALUES('$_SERVER[REMOTE_ADDR]')";$res = mysql_query($sql);};[/code] Quote Link to comment Share on other sites More sharing options...
onlyican Posted November 24, 2006 Author Share Posted November 24, 2006 but I want to know what page that user went on and at what time he went on that page.If it was a case of number of unique hits then I would do thatI have a couple of other ideas, but I want to hear yours first Quote Link to comment Share on other sites More sharing options...
marcus Posted November 24, 2006 Share Posted November 24, 2006 just update their row with what page they are in the last page column using $_SERVER[REQUEST_URI] Quote Link to comment Share on other sites More sharing options...
marcus Posted November 24, 2006 Share Posted November 24, 2006 Then when showing what page that user is on you can easily use fetch assoc or fetch array and echo off last page and link it http://site.com/$lastpageIf they were on index.php the link would be site.com/index.php Quote Link to comment Share on other sites More sharing options...
onlyican Posted November 24, 2006 Author Share Posted November 24, 2006 I dont want to use it in the code in that way, cos I would use sessions for last pageI want to be able to run a queryFind out when a user came on the site, where he came from, what link he then clicked on, then after that, how long was he on each page(Sorry bout using he, it could be a she as well) Quote Link to comment Share on other sites More sharing options...
marcus Posted November 24, 2006 Share Posted November 24, 2006 Your best solution would actually using a different row for each one.Or you can create a table for each IP, but that would be ever worse, haha. I understand what you're saying, and your first theory with over 90,000 rows, yes that would be alot, like only 30-60mb of SQL usage. Quote Link to comment Share on other sites More sharing options...
onlyican Posted November 24, 2006 Author Share Posted November 24, 2006 so I am looking for a way of recording the stats without using MySQL.Thanks mgallforever, but thats the perpose of this post. as I said, I know several options, but I dont want to mention them cos I want people to mention them to me Quote Link to comment Share on other sites More sharing options...
SharkBait Posted November 24, 2006 Share Posted November 24, 2006 A bit similar, but check out [url=http://www.google.com/analytics]Google's Analytics[/url] Not that it will show you how its coded, but its a free service that Google offers that tracks site information.Google bought out Urchin so its similar to one of the more popular sitetracking applications out there.Just an idea.. that's all. Quote Link to comment Share on other sites More sharing options...
onlyican Posted November 25, 2006 Author Share Posted November 25, 2006 Me and my friend registered for this at the same time, just after they released itI have it now, but he does not.Isn't there like a massive waiting list for it Quote Link to comment Share on other sites More sharing options...
onlyican Posted November 25, 2006 Author Share Posted November 25, 2006 I have been told about working with the serverFor Apache Bases hostinghttp://httpd.apache.org/docs/2.0/mod/mod_log_config.html Quote Link to comment Share on other sites More sharing options...
ataria Posted November 25, 2006 Share Posted November 25, 2006 OR. If your using cpanl, you can just go to 'stats' and then go to 'awstats'and it tells you a shitload of useful information.and, it doesn't stress your DB.Try it :] Quote Link to comment Share on other sites More sharing options...
onlyican Posted November 25, 2006 Author Share Posted November 25, 2006 and I know that as I mentioned I want something like awstats, as we use Plesk not Cpanel, and we want to build something in the admin, not another dir like cpanel Quote Link to comment 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.