关于投票有关问题

WBOY
Release: 2016-06-13 12:15:18
Original
1013 people have browsed it

关于投票问题
php大概的怎么让每人每天投N票,谢啦
------解决思路----------------------
在投票人名下计数,每日清空或转移
------解决思路----------------------
table
id     自增id
uid   用戶id
date 日期
votenum 投票次數

判斷是否已超過 n次,如未超過,允許投票。

<br />$n = 10;<br />$uid = 1;<br />$sqlstr = "select votenum from table where uid=".$uid." and date='2015-02-06'";<br />$result = mysql_query($sqlstr) or die(mysql_error());<br /><br />if(!$result){<br />   $sqlstr = "insert into table(uid,date,votenum) values('".$uid."','".date('Y-m-d')."',1)";<br />   mysql_query($sqlstr) or die(mysql_error());<br />}elseif($result['votenum']>$n){<br />    echo '今天你已投票'.$n.'次,不能再投票';<br />    exit();<br />}else{<br />   $sqlstr = "update table set votenum=votenum+1 where uid=".$uid." and date='".date('Y-m-d')."'";<br />   mysql_query($sqlstr) or die(mysql_error());<br />}<br />// 執行投票代碼<br />echo '投票成功';<br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!