php读取30天之内的根据算法排序的代码

yipeiwu_com6年前PHP代码库
复制代码 代码如下:

<?php
$link=mysql_connect("","","")
or die("无法连接到mysql数据库".mysql_error());
mysql_select_db("duyounet",$link);
mysql_query("SET NAMES 'gb2312'",$link);
$day30=time()-60*60*24*30;
$result=mysql_query("select articleid,articlename, (allvote*20+goodnum+allvisit) as dxy_px from jieqi_article_article where postdate>$day30 order by dxy_px desc limit 0,14") or die("查询".$database."数据库出错".mysql_error());
$row=mysql_fetch_row($result);
echo "document.writeln(\"<ul class='ultop'>\")".";\r\n";
while ($row){
echo "document.writeln(\"<li><a href='/modules/article/articleinfo.php?id=".$row[0]."' target='_blank'>".$row[1]."(".$row[2].")</a></li>\");\r\n";
$row=mysql_fetch_row($result);

}
mysql_free_result($result);
mysql_close();
echo "document.writeln(\"</ul>\");\r\n"
?>

substr()
把月份取出+了在放回去
偶是这么做的有更好的方法记得告诉偶
嘿嘿~ 
作者: 太阳雨 发布日期: 2005-4-13 
如果在PHP中处理,用strtotime
[php]
$a="2004/11/01";
$b=strtotime("+6 months",strtotime($a));
echo date('Y/m/d',$b);
[/php]
如果在mysql中处理,用DATE_ADD或ADDDATE函数,也可以直接使用INTERVAL关键字
如:
1、SELECT "2004-11-01" + INTERVAL 6 MONTH;//其中的2004-10-01可以直接使用日期字段
2、SELECT DATE_ADD("2004-11-01", INTERVAL 6 MONTH); 

相关文章

php实现html标签闭合检测与修复方法

本文实例讲述了php实现html标签闭合检测与修复方法。分享给大家供大家参考。具体如下: html标签闭合检测与修复,说的有点大 , 并没有考虑的很完整,没有使用正则表达式, 适用于ht...

hadoop常见错误以及处理方法详解

1、hadoop-root-datanode-master.log 中有如下错误:ERROR org.apache.hadoop.hdfs.server.datanode.DataNod...

使用HMAC-SHA1签名方法详解

加密算法:使用HMAC-SHA1签名方法复制代码 代码如下:    /**     * @brief 使用HMAC-...

php array_chunk()函数用法与注意事项

本文实例讲述了php array_chunk()函数用法与注意事项。分享给大家供大家参考,具体如下: 定义和用法 array_chunk() 函数把数组分割为新的数组块。 其中每个数组的...

用C/C++扩展你的PHP 为你的php增加功能

用C/C++扩展你的PHP 为你的php增加功能

英文版下载: PHP 5 Power Programming https://www.jb51.net/books/61020.html PHP取得成功的一个主要原因之一是她拥有大量的可...