PHP reads code that is sorted by algorithm within 30 days

Source: Internet
Author: User
Copy CodeThe code is as follows:


$link =mysql_connect ("", "", "")
Or Die ("Cannot connect to MySQL database". mysql_error ());
mysql_select_db ("Duyounet", $link);
mysql_query ("SET NAMES ' gb2312 '", $link);
$day 30=time () -60*60*24*30;
$result =mysql_query ("Select Articleid,articlename, (allvote*20+goodnum+allvisit) as dxy_px from Jieqi_article_ Article where postdate> $day the ORDER by dxy_px desc-Limit 0,14 ") or Die (" query ". $database." Database error ". 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 ()
Take the month out + put it back in
There's a better way to do this, remember to tell me that I
hehe ~
Author: Sun Rain Release Date: 2005-4-13
If you are working in PHP, use Strtotime
[PHP]
$a = "2004/11/01";
$b =strtotime ("+6 months", strtotime ($a));
echo Date (' y/m/d ', $b);
[/php]
If you are working in MySQL, you can use the Date_add or Adddate function directly, or the interval keyword
Such as:
1. Select "2004-11-01" + INTERVAL 6 month;//The Date field can be used directly in 2004-10-01
2, select Date_add ("2004-11-01", INTERVAL 6 MONTH);

The above describes the PHP reading within 30 days according to the algorithm sort of code, including the content, I hope the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.