Home >Backend Development >PHP Tutorial >PHP reads the code sorted according to the algorithm within 30 days_PHP tutorial

PHP reads the code sorted according to the algorithm within 30 days_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:52:221008browse

复制代码 代码如下:

$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("")".";rn";
while ($row){
echo "document.writeln("
  • ".$row[1]."(".$row[2].")
  • ");rn";
    $row=mysql_fetch_row($result);

    }
    mysql_free_result($result);
    mysql_close();
    echo "document.writeln("");rn"
    ?>

    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); 

    www.bkjia.comtruehttp://www.bkjia.com/PHPjc/318944.htmlTechArticle复制代码 代码如下: ?php $link=mysql_connect("","","") ordie("无法连接到mysql数据库".mysql_error()); mysql_select_db("duyounet",$link); mysql_query("SETNAMES'gb2312'...
    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn