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:
- <?php
- /*
- * Author : Fanglor
- * Email : Fanlor@163.com
- * Url : www.skyleft.com
- * Date : 2009-9-22
- */
- include "config.php";
- $today_start = mktime(0,0,0,date('m'),date('d'),date('Y'));
- $today_end = mktime(0,0,0,date('m'),date('d')+1,date('Y'));
- echo $sql = "SELECT * FROM `article` WHERE `article_time` BETWEEN '{$today_start}' AND '{$today_end}'";
- $list = getAll ($sql);
- if ($list) {
- echo "<pre>";
- var_dump ($list);
- echo "</pre>";
- }
-
- ?>
-
Print result:
- SELECT * FROM `article` WHERE `article_time` BETWEEN '1253548800' AND '1253635200'
-
- array(2) {
- [0]=>
- array(7) {
- ["article_id"]=>
- string(2) "30"
- ["article_title"]=>
- string(14) "11111111111111"
- ["article_count"]=>
- string(1) "0"
- ["article_type"]=>
- string(1) "1"
- ["article_tag"]=>
- string(14) "22222222222222"
- ["article_content"]=>
- string(27) "111111111111111111111111111"
- ["article_time"]=>
- string(10) "1253626081"
- }
- [1]=>
- array(7) {
- ["article_id"]=>
- string(2) "31"
- ["article_title"]=>
- string(5) "22222"
- ["article_count"]=>
- string(1) "0"
- ["article_type"]=>
- string(1) "8"
- ["article_tag"]=>
- string(14) "22222222222222"
- ["article_content"]=>
- string(27) "222222222222222222222222222"
- ["article_time"]=>
- string(10) "1253626095"
- }
- }
-
-
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