我已经得到了一些帮助,但不确定为什么这不起作用。
我正在尝试使用表单让用户过滤他们的活动(存储在数据库中)
我的代码:
$_GET['from'] = '01/11/2013';
$_GET['to'] = '25/11/2013';
$from = DateTime::createFromFormat('d/m/Y', $_GET['from']);
$to = DateTime::createFromFormat('d/m/Y', $_GET['to']);
$sql = "
SELECT * FROM transfer
WHERE personID = $user AND DATE(time) BETWEEN '%s' AND '%s'
";
$sql = sprintf($sql, $from->format('Y-m-d'), $to->format('Y-m-d'));
print_r($sql);
这打印
SELECT * FROM transfer WHERE personID = 84587749 AND DATE(time) BETWEEN '2013-11-01' AND '2013-11-14'
当我在 PHPmyadmin 中查询它时,它会显示记录,但没有显示在我的页面中?