您现在的位置是:首页 > cms教程 > 帝国CMS教程帝国CMS教程

帝国CMS按小时和按天等发布文章数量的统计方法

绮纹2023-04-20帝国CMS教程已有人查阅

导读按照小时显示更新数量,统计昨天发表的文章数量,当前栏目本周更新:注释:按栏目统计一周发布文章数 加 classid='栏目id'

按照小时显示更新数量
用sql调用
6小时:<?=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_表 where newstime>UNIX_TIMESTAMP()-6*3600")?>
12小时:<?=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_表 where newstime>UNIX_TIMESTAMP()-12*3600")?>
24小时:<?=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_表 where newstime>UNIX_TIMESTAMP()-24*3600")?>
一个星期:<?=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_表 where newstime>UNIX_TIMESTAMP()-86400*7")?>
一个月:<?=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_表 where newstime>UNIX_TIMESTAMP()-86400*30")?>
灵动标签调用
6小时:[e:loop={'select count(*) as total from [!db.pre!]ecms_表 where newstime>UNIX_TIMESTAMP()-6*3600',0,24,0}]<?=$bqr[total]?>[/e:loop]
12小时:[e:loop={'select count(*) as total from [!db.pre!]ecms_表 where newstime>UNIX_TIMESTAMP()-12*3600',0,24,0}]<?=$bqr[total]?>[/e:loop]
24小时:[e:loop={'select count(*) as total from [!db.pre!]ecms_表 where newstime>UNIX_TIMESTAMP()-24*3600',0,24,0}]<?=$bqr[total]?>[/e:loop]
一个星期:[e:loop={'select count(*) as total from [!db.pre!]ecms_表 where newstime>UNIX_TIMESTAMP()-86400*7',0,24,0}]<?=$bqr[total]?>[/e:loop]
一个月:[e:loop={'select count(*) as total from [!db.pre!]ecms_表 where newstime>UNIX_TIMESTAMP()-86400*30',0,24,0}]<?=$bqr[total]?>[/e:loop]
12*3600即12小时
86400*7即7天
统计昨天发表的文章数量
<?php
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
?>
[e:loop={"select count(*) as total from [!db.pre!]ecms_news where newstime BETWEEN $beginYesterday and $endYesterday",1,24,0}]<?=$bqr[total]?>[/e:loop] 篇 </li>
当前栏目本周更新:
<?=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_news where classid='$GLOBALS[navclassid]' and newstime >UNIX_TIMESTAMP()-86400*7")?>
注释:按栏目统计一周发布文章数 加 classid='栏目id'
按当前栏目一周发布文章数 加 classid='$GLOBALS[navclassid]'
//php获取今日开始时间戳和结束时间戳
$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
//php获取昨日起始时间戳和结束时间戳 (即:前一天)
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
//调取这两天(包括今天):(修改昨天)--date('d')-1:这两天 、date('d')-2:这三天、以此类推(注意:$beginYesterday、$endYesterday这两个未改动,还是沿用的昨天的名称)
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
//调取前两天(修改昨天)--date('d')-2:前两天 、date('d')-3:前三天、以此类推(注意:$beginYesterday、$endYesterday这两个未改动,还是沿用的昨天的名称)
$beginYesterday=mktime(0,0,0,date('m'),date('d')-2,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
//php获取上周起始时间戳和结束时间戳
$beginLastweek=mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));
$endLastweek=mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));
//php获取本周起始时间戳和结束时间戳
$beginThisweek=mktime(0,0 ,0,date("m"),date("d")-date("w")+1,date("Y"));
$endThisweek=mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
//php获取上月起始时间戳和结束时间戳
$beginLastmonth=mktime(0,0,0,date("m")-1,1,date("Y"))
$endLastmonth=mktime(23,59,59,date("m"),0,date("Y"))
//php获取本月起始时间戳和结束时间戳
$beginThismonth=mktime(0,0,0,date('m'),1,date('Y'));
$endThismonth=mktime(23,59,59,date('m'),date('t'),date('Y'))

本文标签:

很赞哦! ()

相关源码

  • (自适应响应式)英文外贸医疗科研耗材设备pbootcms网站模板为医疗设备和外贸企业设计的响应式网站模板,基于PbootCMS系统开发。突出医疗产品认证展示和国际化特性,通过专业化的产品参数展示模块和文档管理系统,满足医疗行业严格的信息披露要求。查看源码
  • pbootcms模板(自适应手机版)红色响应式单位机构类网站自适应响应式单位机构网站模板 | PbootCMS内核开发为机构组织设计的响应式网站模板,采用PbootCMS内核开发,支持一键替换行业内容,满足多元化场景需求。查看源码
  • 帝国CMS7.5二次元COS漫展网站模板源码免费下载本模板基于帝国CMS 7.5版本深度开发,为二次元文化分享领域设计。采用UTF-8编码,支持中文内容展示,特别适用于COSPLAY作品展示、漫展信息发布等二次元相关内容的网站建设。模板结构清晰,布局合理,充分考虑了二次元用户群体的浏览习惯和审美需求。查看源码
  • (自适应)双语网络电子摄像头设备pbootcms网站模板下载核心功能定位:基于PbootCMS开发的双语摄像头企业官网模板,深度适配产品规格书展示、实时监控演示、解决方案呈现等业务场景,支持中英文内容一键切换。查看源码
  • (自适应手机端)英文外贸电子产品通用pbootcms模板源码下载为电子产品外贸企业设计的响应式网站模板,采用PbootCMS开发内核,支持多语言展示。模板默认集成产品展示系统、询价表单模块和企业资质展示区,满足跨境贸易基础需求。整站采用模块化设计,便于扩展业务场景。查看源码
  • (自适应)帝国cms7.5模板新闻资讯门户带会员中心基于帝国CMS7.5内核开发的HTML5响应式模板,为新闻机构、媒体门户及资讯聚合平台设计。通过模块化布局实现图文混排查看源码
分享笔记 (共有 篇笔记)
验证码: