beboo002 Posted October 18, 2007 Share Posted October 18, 2007 hello all how we calculate page view in php. need help any weblink any clue thanks Link to comment https://forums.phpfreaks.com/topic/73792-how-to-calculate-page-view-in-php/ Share on other sites More sharing options...
MadTechie Posted October 18, 2007 Share Posted October 18, 2007 what do you mean by "Page View" ? Link to comment https://forums.phpfreaks.com/topic/73792-how-to-calculate-page-view-in-php/#findComment-372278 Share on other sites More sharing options...
Foser Posted October 18, 2007 Share Posted October 18, 2007 depends how filtered you want it, but just do like a query to mysql adding 1 to the a "INT" field. But thats very basic, so if you refresh it will count you again. Depends how you want it to behave. Link to comment https://forums.phpfreaks.com/topic/73792-how-to-calculate-page-view-in-php/#findComment-372281 Share on other sites More sharing options...
Wes1890 Posted October 18, 2007 Share Posted October 18, 2007 On every page you want to calculate page views do this: //Update views mysql_query("UPDATE YOURTABLE SET page_views=page_views+1 WHERE page_id=".$page_id."") or die (mysql_error()); Be sure to change your table and column names though. Link to comment https://forums.phpfreaks.com/topic/73792-how-to-calculate-page-view-in-php/#findComment-372283 Share on other sites More sharing options...
flappy_warbucks Posted October 18, 2007 Share Posted October 18, 2007 the problem with the above examples is that if someone was to go through your site and go to your home page numirous times, it would count them as a hit. what i do is something like this: if (!isset($_COOKIE['home'])) // check to see if they have been on the homepage before and if they have not the do below. { setcookie("home","1",time()+3600); //set a cookie so that you know they have been to your home page within the last hour. mysql_query("update table set visitors=visitors+1"); //update the database. } that way you dont get loads of hits on that page if someone keeps going throught the site and hitting the same page all over again. Link to comment https://forums.phpfreaks.com/topic/73792-how-to-calculate-page-view-in-php/#findComment-372286 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.