thara Posted September 4, 2012 Share Posted September 4, 2012 Hello everyone... In my website, I am registering teacher and on my home page display all registered teachers. And there are links to access their profiles. My problem is I need to count the visitors who are visiting to teacher profile pages. Reason is in my teacher profile page I need to add an option like (views 100 time). How is the best way to do this, and can someone point me in the right direction? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/267991-counting-page-visiting/ Share on other sites More sharing options...
spiderwell Posted September 4, 2012 Share Posted September 4, 2012 i am assuming that the teachers details are stored in a database and all pulled through the same template page, like teacherprofile.php?id=12345. Simply add to table in the database a column called views, and have it add 1 to the views column when you pull out the data to show. This is certainly one method that would work for you Quote Link to comment https://forums.phpfreaks.com/topic/267991-counting-page-visiting/#findComment-1375152 Share on other sites More sharing options...
thara Posted September 4, 2012 Author Share Posted September 4, 2012 thanks for reply... your assumption is correct all teacher profile generate from one template page. Your answer is little bit confuse me. can you kindly give me an example with your answer. thanks in advance.... Quote Link to comment https://forums.phpfreaks.com/topic/267991-counting-page-visiting/#findComment-1375156 Share on other sites More sharing options...
Jessica Posted September 4, 2012 Share Posted September 4, 2012 Simply add to table in the database a column called views, and have it add 1 to the views column when you pull out the data to show. What is confusing about it? Why don't you try to write some code, and we can help when you get stuck. Quote Link to comment https://forums.phpfreaks.com/topic/267991-counting-page-visiting/#findComment-1375158 Share on other sites More sharing options...
The Little Guy Posted September 4, 2012 Share Posted September 4, 2012 I am not sure what your trying to accomplish, but this should get the number of people who are currently viewing the page: /* Requires a unique key on (teacher_id, ip) */ mysql_query("insert into teacher_views (teacher_id, ip, view_time) values ($teacher_id, inet_aton($ip), now()) on duplicate key update view_time = values(view_time)"); $sql = mysql_query("select count(*) from teacher_views where view_time >= date_sub(now(), interval 5 minute)"); $row = mysql_fetch_array($sql); $views = $row[0]; Quote Link to comment https://forums.phpfreaks.com/topic/267991-counting-page-visiting/#findComment-1375292 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.