例如,我有两个页面:page.php?id=1
和page.php?id=2
。当用户点击page.php?id=1
时,它将计为1个视图, mysql 将保存IP地址以计算唯一身份访问者。但如果同一位用户点击page.php?id=2
,则不会将其视为唯一身份访问者。
这是MySQLi代码:
$ip = $_SERVER['REMOTE_ADDR'];
$id = htmlspecialchars($_GET["keywordid"]);
$encode = ip2long($ip);
$viewcheck = mysqli_query($con,"SELECT INET_NTOA(ip) FROM ip_address WHERE ip = $encode");
$viewrow = mysqli_num_rows($viewcheck);
if($viewrow == 0) { mysqli_query($con,"UPDATE keywords SET keyword_count = keyword_count + 1 where keyword_id = $id");
}