Jump to content

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

 

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.