我编码了这个:
<?php
include("includes/config.php");
if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['username']))
{
if(is_numeric($_GET['num']) && mysql_real_escape_string($_GET['id'])){
$username=$_SESSION['username'];
$video_id=$_GET['id'];
$video_num=$_GET['num'];
$checknum=mysql_query("select visitedpage.video_id,visitedpage.video_num from visitedpage where video_num='$video_num'");
$num=mysql_num_rows($checknum);
if($num < 1){
$savepage=mysql_query("insert into visitedpage(username,video_id,video_num) values ('$username','$video_id','$video_num')");
}
if($num < 1 ){
$get=mysql_query("select users.percent from users where username='$username'");
$fetch=mysql_fetch_assoc($get);
$now=$fetch['percent'];
$add=1;
$sum=$now + $add;
$update=mysql_query("update users set percent='$sum' where username='$username'");
}
}}
?>
我希望当用户仍在页面中大约 10 分钟时执行代码
我试过 (sleep()) 但这将停止执行页面的其余部分,我只需要延迟执行这个片段......