Jump to content

counting page visiting...


thara

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/267991-counting-page-visiting/
Share on other sites

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

 

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];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.