MySQL query application -- Query all articles published on the current day

Source: Internet
Author: User

I believe you will not be familiar with MySQL query. The following describes how to use MySQL query to query all articles published on the current day. I hope it will help you learn about MySQL query.

Code:

 
 
  1. <?php 
  2. /*  
  3. * Author : Fanglor  
  4. * Email : Fanlor@163.com  
  5. * Url    : www.skyleft.com  
  6. * Date   : 2009-9-22  
  7. */  
  8. include "config.php";  
  9. $today_start = mktime(0,0,0,date('m'),date('d'),date('Y'));  
  10. $today_end = mktime(0,0,0,date('m'),date('d')+1,date('Y'));  
  11. echo $sql = "SELECT * FROM `article` WHERE `article_time` BETWEEN '{$today_start}' AND '{$today_end}'";  
  12. $list = getAll ($sql);  
  13. if ($list) {  
  14. echo "<pre>";  
  15. var_dump ($list);  
  16. echo "</pre>";  
  17. }  
  18.  
  19. ?> 
  20.  

Print result:

 
 
  1. SELECT * FROM `article` WHERE `article_time` BETWEEN '1253548800' AND '1253635200'  
  2.  
  3. array(2) {  
  4.   [0]=> 
  5.   array(7) {  
  6.     ["article_id"]=> 
  7.     string(2) "30"  
  8.     ["article_title"]=> 
  9.     string(14) "11111111111111"  
  10.     ["article_count"]=> 
  11.     string(1) "0"  
  12.     ["article_type"]=> 
  13.     string(1) "1"  
  14.     ["article_tag"]=> 
  15.     string(14) "22222222222222"  
  16.     ["article_content"]=> 
  17.     string(27) "111111111111111111111111111"  
  18.     ["article_time"]=> 
  19.     string(10) "1253626081"  
  20.   }  
  21.   [1]=> 
  22.   array(7) {  
  23.     ["article_id"]=> 
  24.     string(2) "31"  
  25.     ["article_title"]=> 
  26.     string(5) "22222"  
  27.     ["article_count"]=> 
  28.     string(1) "0"  
  29.     ["article_type"]=> 
  30.     string(1) "8"  
  31.     ["article_tag"]=> 
  32.     string(14) "22222222222222"  
  33.     ["article_content"]=> 
  34.     string(27) "222222222222222222222222222"  
  35.     ["article_time"]=> 
  36.     string(10) "1253626095"  
  37.   }  
  38. }  
  39.    
  40.  

MySQL Date and Time Functions

Transformed from the MySQL Query Class of discuz

Use the Limit parameter to optimize MySQL queries

In-depth parsing of MySQL query Cache Mechanism

Common MySQL command line tools

Related Article

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.