时间:2021-07-01 10:21:17 帮助过:16人阅读
这是数据库的设计
@$love=$_POST['id'];
if(isset($love)){
$query="SELECT * FROM ecs_article_love where article_id='$love' AND ip='$realip'";
$result=mysql_query($query);
$row=mysql_fetch_row($result);
//dump($row);
$ip1=$row[2];
$ip2=$realip;
$todaytime=strtotime(date('Y-m-d'));
$iptime=$row[3];
//$endtime=strtotime(date('Y-m-d',strtotime('+1 day')));
//echo $todaytime;
if(strcmp($ip1,$ip2)==0){
echo 2;
}
if(!$row && $iptime<$todaytime){
$query="INSERT INTO ecs_article_love (ip,article_id,iptime) VALUES ('".$ip2."','".$love."','".$todaytime."')";
mysql_query($query);
//echo "";
$sql = $GLOBALS['db']->query("update ".$GLOBALS['ecs']->table('article')." set love=love+1 where article_id=$love");
echo 1;
}
die();
}