Php code sorted by algorithm within 30 days of reading _ PHP Tutorial

Source: Internet
Author: User
Php reads the code sorted by algorithm within 30 days. Copy the code as follows :? Php $ linkmysql_connect (,) ordie (unable to connect to mysql database. mysql_error (); mysql_select_db (duyounet, $ link); mysql_query (SETNAMESgb2312 The code is as follows:


$ Link = mysql_connect ("","","")
Or die ("unable to connect to mysql database". 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 ("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 ()
Remove the month and put it back.
Even if there is a better way to do this, remember to tell me
Hey hey ~
Author: Sun rain Release date:
If it is processed in PHP, use strtotime
[Php]
$ A = "2004/11/01 ";
$ B = strtotime ("+ 6 months", strtotime ($ ));
Echo date ('Y/m/D', $ B );
[/Php]
If you use the DATE_ADD or ADDDATE functions for processing in mysql, you can also use the INTERVAL keyword directly.
For example:
1. SELECT "2004-11-01" + INTERVAL 6 MONTH; // you can directly use the date field 2004-10-01.
2. SELECT DATE_ADD ("2004-11-01", INTERVAL 6 MONTH );

The http://www.bkjia.com/PHPjc/318944.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/318944.htmlTechArticle code is as follows :? Php $ link = mysql_connect ("", "", "") ordie ("unable to connect to mysql database ". mysql_error (); mysql_select_db ("duyounet", $ link); mysql_query ("SETNAMES 'gb2312 '...

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.