首页 > 后端开发 > php教程 > 关于php的判断语句

关于php的判断语句

WBOY
发布: 2016-06-23 14:27:32
原创
1091 人浏览过

	$pubdate = $dsql->GetOne("select pubdate from article where writer ='".$writer."' order by id desc limit 1");	if((time()-$pubdate['pubdate'])<(3600*24)){		ShowMsg("对不起,一个会员每天只能发一篇文章!","-1","0",5000);		exit;	}
登录后复制


以上判断一个会员在一天内只能提交一篇文档,想修改成可以提交3篇,应该怎么做?


回复讨论(解决方案)

$pubdate = $dsql->GetOne("select pubdate,writer,count(pubdate) as total from article where writer ='".$writer."' and pubdate<".strtotime("-1 day")." limit 3");
if($pubdate['total'])==3){
ShowMsg("对不起,一个会员每天只能发一篇文章!","-1","0",5000);
exit;
}


mysql查询一天内提交的文章数,如果>=3不能提交

$pubdate = $dsql->GetOne("select pubdate,writer,count(pubdate) as total from article where writer ='".$writer."' and pubdate<".strtotime("-1 day")." limit 3");
if($pubdate['total'])==3){
ShowMsg("对不起,一个会员每天只能发一篇文章!","-1","0",5000);
exit;
}


mysql查询一天内提交的文章数,如果>=3不能提交

mysql跑不起来。跪求检查一下。
另外:if($pubdate['total'])==3)应该是if(($pubdate['total'])==3)这样吧?
数据库字段:
数据库名称(article)
会员名称(writer)
发布时间(pubdate)

原代码改为

$n = 1; //你指定的篇数$pubdate = $dsql->GetOne("select count(*) as cnt from article where FROM_UNIXTIME(pubdate,'%Y%m%d')=DATE_FORMAT(now(),'%Y%m%d') and writer ='".$writer."' order by id desc limit 1");if($pubdate['pubdate'] > $n){    ShowMsg("对不起,一个会员每天只能发 $n 篇文章!","-1","0",5000);    exit;}
登录后复制

还是版主给力,学习了

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板