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

yipeiwu_com5年前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+pdo实现的购物车类完整示例

本文实例讲述了php+pdo实现的购物车类。分享给大家供大家参考,具体如下:<?php session_start(); class Cart {  &n...

PHP扩展模块Pecl、Pear以及Perl的区别

一、简短总结:pear:一个书写的比较规范,国外较流行的工具箱代码集pecl:php扩展包,但不属于php基本扩展范围perl:一种早于php出现的脚本级语言,php借鉴了他的正则表达式...

PHP实现根据图片色界在不同位置加水印的方法

本文实例讲述了PHP实现根据图片色界在不同位置加水印的方法。分享给大家供大家参考。具体如下: 在使用php编程的时候, 很多时候需要对上传的图片加水印,来确定图片版权和出处. 但是,一般...

simplehtmldom Doc api帮助文档

API Reference Helper functions object str_get_html ( string $content ) Creates a DOM object f...

Cygwin中安装PHP方法步骤

1.在Cygwin中安装apt-cyg包管理工具 复制代码 代码如下: $ wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg $...