时间:2021-07-01 10:21:17 帮助过:14人阅读
$n = 10;
$uid = 1;
$sqlstr = "select votenum from table where uid=".$uid." and date='2015-02-06'";
$result = mysql_query($sqlstr) or die(mysql_error());
if(!$result){
$sqlstr = "insert into table(uid,date,votenum) values('".$uid."','".date('Y-m-d')."',1)";
mysql_query($sqlstr) or die(mysql_error());
}elseif($result['votenum']>$n){
echo '今天你已投票'.$n.'次,不能再投票';
exit();
}else{
$sqlstr = "update table set votenum=votenum+1 where uid=".$uid." and date='".date('Y-m-d')."'";
mysql_query($sqlstr) or die(mysql_error());
}
// 執行投票代碼
echo '投票成功';