I’m trying to count the number of views of people who visit the page using php

  php

I’m trying to execute this php script but I just want it to be executed after 30s to make sure that the user has really visited that page so I used sleep(); function but it preventing the whole code to run

and this code will run every time the user refresh a page

where

$vi is the variable that store the session
$vi=$_SESSION['views']=1;

$update_views="UPDATE `videos` SET `views` = '$vi' WHERE `videos`.`ID` = $ID";
   $query=mysqli_query($con,$update_views);

Source: Ask PHP

LEAVE A COMMENT