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 substr 截取字符串出现乱码问题解决方法[utf8与gb2312]

substr --- 取得部份字符串 语法 : string substr (string string, int start [, int length]) 说明 : substr(...

PHP __autoload函数(自动载入类文件)的使用方法

这也是OO设计的基本思想之一。在PHP5之前,如果需要使用一个类,只需要直接使用include/require将其包含进来即可。下面是一个实际的例子: 复制代码 代码如下: class...

php不允许用户提交空表单(php空值判断)

可以修改代码,添加些判断: 复制代码 代码如下:  if(empty($_POST['name'])){  echo "俗话说的好,雁过留声人过留...

php打开本地exe程序,js打开本地exe应用程序,并传递相关参数方法

实例如下: <? //include_once("inc/auth.inc.php"); include_once("inc/conn.php"); $HTML_PAG...

PHPCMS的使用小结

下面我讲讲关于这套系统的加载流程 定义根目录,定义include目录 加载核心文件 配置文件'config.inc.php' 全局函数'global.func.php' 目录操作函数'd...