好的,所以我需要在页面加载时更新两个表。这是代码:
<?php include'connects.php';
//Test if it is a shared client
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
$ip=$_SERVER['HTTP_CLIENT_IP'];
//Is it a proxy address
}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip=$_SERVER['REMOTE_ADDR'];
}
$ip = ip2long($ip);
mysqli_query($con,"INSERT INTO visits (ip_adress) VALUES ('$ip') ON DUPLICATE KEY
UPDATE visit = visit + 1");
mysqli_query($con,"UPDATE ip_visits SET total_visits = total_visits + 1");
mysqli_close($con);
?>
现在我有第二个表需要执行与此顶层表相同的功能:
mysqli_query($con,"INSERT INTO indVisits (ip_adress) VALUES ('$ip') ON DUPLICATE KEY
UPDATE visits = visits + 1");
mysqli_query($con,"UPDATE totalVisits SET visit = visit + 1");