I am working on a project where only the message heading is displayed on the main page and when you click the heading, the full post is uploaded to another posts.php page for this code:
<a href="posts.php?postId=<?php echo $row['posts_id'] ?>"><?php echo $row['title']; ?></a>
Now, to count post messages, I have a hits column in my posts table, initially the hits value is set to 0 , and whenever the message opens, the hits value is increased by 1, for this my code is in posts.php
$id = $_GET['postId']; $sql = "UPDATE posts SET hits = hits + 1 WHERE post_id = $id";
But this is not a good practice for tracking message views, since views are updated when the page is refreshed. I want a clean system to track message views when it increases by one for each individual user or viewer, regardless of how many times the same user / visitor views the same message (as in stackoverflow). Like tracking them by their IP address or something else, just an idea (how these guys do it) or how the stuff works will be enough for me to get started.
source share