MySQL查询相信大家都不会陌生,下面将为您介绍如何使用MySQL查询实现查询当天发布的所有文章,希望对您学习MySQL查询方面能有所帮助。
代码:
- <?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>";
- }
- ?>
打印结果:
- 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"
- }
- }
【编辑推荐】