php讀取30天之內的根據演算法排序的代碼

來源:互聯網
上載者:User
複製代碼 代碼如下:


$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(\"

    \")".";\r\n";
    while ($row){
    echo "document.writeln(\"
  • ".$row[1]."(".$row[2].")
  • \");\r\n";
    $row=mysql_fetch_row($result);
    }
    mysql_free_result($result);
    mysql_close();
    echo "document.writeln(\"
\");\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讀取30天之內的根據演算法排序的代碼,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.