I'm trying to create a hit counter, this code updates my column once per session, but what I want is to update my column whenever the user views a new page.
if(!isset($_SESSION))session_start();
if(empty($_SESSION['counter'])){
$_SESSION['counter'] = 1;
$mread = $conn->prepare("UPDATE table SET counter = counter + 1 WHERE id = :id");
$mread->bindParam(':id', $id, PDO::PARAM_INT);
$mread->execute();
};
If I only use the query UPDATE
it will refresh my column whenever I reload the page, and that's not what I want. I want to update my column whenever the user views a new page.
How do I do this?