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

帝国CMS按照日期怎么调用当日更新信息

问旋2023-05-30 23:10:06帝国CMS教程已有人查阅

导读帝国CMS按照日期调用当日更新信息教程

帝国CMS按照日期调用当日更新信息教程

<?php
require("../class/connect.php");
include("../class/config.php");
include("../class/q_functions.php");
include("../class/db_sql.php");
include("../class/class.php");
$link=db_connect();
$empire=new mysqlquery();
//参数设置
$rili = rili($date,'',true);
$curtime = time();
//获得时间戳
if(empty($date)){
        $timestamp = $curtime;
}else{
        $timestamp = strtotime($date);
}
        $selectedyear = date('Y',$timestamp);
        $selectedmonth = date('n',$timestamp);
        $selectedday = date('d',$timestamp);
       
        $starttime = mktime(0,0,0,$selectedmonth,$selectedday,$selectedyear);
        $endtime = $starttime+86400;
$where = '';
$tid = intval($tid);
if($tid > 0){
        $where = " and typeid=$tid";
}
$query ("select title from phome_ecms_article where newstime >$starttime and newstime <$endtime $where");
$sql=$empire->query($query);
$sql=$empire->execute();
$list = array();
while($row = $db->getarray())
{
        $row['pubdate'] = date('H点i分',$row['pubdate']);
        $list[] = $row;
}
function rili($date, $file = '', $nomax = false)
{
        $curtime = time();
        //获得时间戳
        if(empty($date)){
                $timestamp = $curtime;
        }else{
                $timestamp = strtotime($date);
        }
       
        $selectedyear = date('Y',$timestamp);
        $selectedmonth = date('n',$timestamp);
        $selectedday = date('d',$timestamp);
        //给定月份第一天星期几
        $firstday = date('w',mktime(0,0,0,$selectedmonth,1,$selectedyear));
        ////给定月份所应有的天数
        $lastday = date('t',$timestamp);//给定月份所应有的天数
       
        $preyear = date('Y',mktime(0,0,0,$selectedmonth,0,$selectedyear));
        $nextyear = date('Y',mktime(0,0,0,$selectedmonth,$lastday+1,$selectedyear));
        $premonth = date('n',mktime(0,0,0,$selectedmonth,0,$selectedyear));
        $nextmonth = date('n',mktime(0,0,0,$selectedmonth,$lastday+1,$selectedyear));
        $premonthdays = date('t',mktime(0,0,0,$selectedmonth,0,$selectedyear));
        $nextmonthdays = date('t',mktime(0,0,0,$selectedmonth,$lastday+1,$selectedyear));
        $preday = min($selectedday,$premonthdays);
        $nextday = min($selectedday,$nextmonthdays);
       
       
        //显示日历头
        $days = array("日","一","二","三","四","五","六");
        $months = array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");
        $monthName = $months[$selectedmonth-1];
       
        $str = "<table bgcolor="#F0F9EE">";
        $str .= "<caption valign="center"><a href="$file?date=$preyear-$premonth-$preday"><<</a> <b> $selectedyear  $monthName</b> ";
        if($nomax && mktime(0,0,0,$nextmonth,1,$nextyear) > $curtime){
                $str .= ">></caption>";
        }else{
                $str .= "<a href="$file?date=$nextyear-$nextmonth-$nextday">>></a></caption>";
        }
        $str .= "<tr>";
        for($i=0;$i<7;$i++){
        $str .= "<td width=10%>$days[$i]</td>";
        }
        $str .= "</tr>";
        //空出当月第一天的位置
        $i = 0;
        while($i < $firstday){
                $str .= "<td></td>";
                $i++;
        }
        $day = 0;
        while($day < $lastday){
                if(($i % 7) == 0){
                        $str .= "</tr><tr>";
                }
                $day++;
                $i++;
                //当天用红色表示
                if($day == $selectedday){
                        $str .= "<td class=calendarToday align=center><font color=#ffffff>$day</font></td>";
                }else {
                        if($nomax && mktime(0,0,0,$selectedmonth,$day,$selectedyear) > $curtime){
                                $str .= "<td>$day</td>";
                        }else{
                                $str .= "<td><a href="$file?date=$selectedyear-$selectedmonth-$day">$day</a></td>";
                        }
                }
               
        }
        $str .= "</tr></table>";
        return $str;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>BODY {
        PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 14px; PADDING-BOTTOM: 0px; MARGIN: 5px 10px; PADDING-TOP: 0px
}
#header {
        PADDING-LEFT: 5px
}
IMG {
        BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px
}
.STYLE1 {font-size: small}
.left {
        FLOAT: left
}
.t {
     PADDING-top: 5px
}
.right {
        FLOAT: right
}
.calendarHeader {
        FONT-WEIGHT: bolder; COLOR: #c00; BACKGROUND-COLOR: #ffc
}
.calendarToday {
        COLOR: #fff; BACKGROUND-COLOR: #f00
}
.calendarToday A:link {
        COLOR: #fff
}
.calendarToday A:visited {
        COLOR: #fff
}
.calendarToday A:hover {
        COLOR: #fff
}
.calendar {
        COLOR: #333; BACKGROUND-COLOR: #ffc
}
A.hot:link {
        COLOR: #f00
}
A.hot:visited {
        COLOR: #f00
}
A:link {
        COLOR: #009
}
A:visited {
        COLOR: #009
}
A:hover {
        COLOR: #c00
}
.clear {
        CLEAR: both; FONT-SIZE: 0px; VISIBILITY: hidden; LINE-HEIGHT: 0px; HEIGHT: 0px
}
#menu {
        PADDING-LEFT: 10px; BACKGROUND: #efefef; LINE-HEIGHT: 26px; BORDER-BOTTOM: #009 1px solid
}
#menu A {
        TEXT-DECORATION: none
}
#server A {
        TEXT-DECORATION: none
}
#indexl {
        PADDING-RIGHT: 10px; PADDING-LEFT: 10px; FLOAT: left; PADDING-BOTTOM: 10px; PADDING-TOP: 10px
}
.yester {
        MARGIN-TOP: 6px; LINE-HEIGHT: 22px; TEXT-ALIGN: center
}
#indexr {
        PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FLOAT: left; PADDING-BOTTOM: 0px; BORDER-LEFT: #009 1px solid; LINE-HEIGHT: 22px; PADDING-TOP: 0px
}
#indexr SPAN {
        FONT-SIZE: 12px; COLOR: #333
}
#indexr A:link {
        TEXT-DECORATION: none
}
#indexr A:visited {
        TEXT-DECORATION: none
}
#indexr A:hover {
        TEXT-DECORATION: underline
}
#indexr .top {
        PADDING-LEFT: 20px; FONT-WEIGHT: bold; BACKGROUND: #F0F9EE; COLOR: #333; LINE-HEIGHT: 26px; BORDER-BOTTOM: #ccc 1px solid
}
#indexr .bot {
        PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; HEIGHT: 100%; LINE-HEIGHT: 3px
}
#server {
        BORDER-TOP: #009 1px solid; FONT-SIZE: 12px; BACKGROUND: #efefef; LINE-HEIGHT: 26px; TEXT-ALIGN: center
}
#copy {
        FONT-SIZE: 12px; LINE-HEIGHT: 26px; TEXT-ALIGN: center
}
</STYLE>
</HEAD>
<BODY>
<div id=indexl>
<?php
echo $rili;//这里输入的是日历,放到你想要的位置
?>
</div>
<div id=indexr>
<div class=top>
Name </div>
<div class=bot>
<?=$r=$empire->fetch1($query);
?>
</div></div>
<div class=clear></div>
</div>
</div>
</body>
</html>

将第一部分

$query ("select title from phome_ecms_article where newstime >$starttime and newstime <$endtime $where");
$sql=$empire->query($query);
$sql=$empire->execute();
$list = array();
while($row = $db->getarray())
{
        $row['pubdate'] = date('H点i分',$row['pubdate']);
        $list[] = $row;
}

换成:

$r=$empire->fetch1("select title from phome_ecms_article where newstime like '%".date("Y-m-d")."%' limit 1");

第二个

<?=$r=$empire->fetch1($query);
?>

换成

<?=$r[title]?>

本文标签:

很赞哦! ()

留言与评论 (共有 条评论)
验证码:

相关标签