我试图显示两个日期之间created_at
日期的行数。
这是我的代码:
$result=mysql_query("select * from payments
where created_at between '2013/10/01 00:00:00' and '2013/10/30 00:00:00'")
or die('You need to add an administrator ' );
$counter = mysql_query("select * from payments
where created_at between '2013/10/01 00:00:00' and '2013/10/30 00:00:00'");
$row = mysql_fetch_array($result);
$id = $row['id'];
$num = mysql_fetch_array($counter);
$countjan = $num["id"];
然而,当我回应
<?php echo"$jan";?>
这显示为0
我知道如何让这个工作
P.s在此日期范围内有1行
答案 0 :(得分:0)
您可以这样查询:
SELECT COUNT(*) FROM your_table WHERE created_at >= '2013/10/01 00:00:00' AND created_at <= '2013/10/30 00:00:00'
BTW:您应该使用MySQL日期格式或时间戳。
答案 1 :(得分:0)
试试这个
$res=mysql_query("SELECT * FROM your_table WHERE created_at >= '2013/10/01 00:00:00' AND created_at <= '2013/10/30 00:00:00'");
if($res)
{
$count=mysql_num_rows($res);
echo $count;
}
答案 2 :(得分:0)
SELECT COUNT(*) FROM your_table WHERE created_at >= '2013/10/01 00:00:00' AND created_at <= '2013/10/30 00:00:00'