• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

关于php的判断语句

php 搞代码 3年前 (2022-01-23) 23次浏览 已收录 0个评论
文章目录[隐藏]
	$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;	}

以上判断一个会员在一%本文@来源gao@!dai!ma.com搞$$代^@码!网搞代gaodaima码天内只能提交一篇文档,想修改成可以提交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;}

还是版主给力,学习了


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:关于php的判断语句
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址