gpt4 book ai didi

PHP 和 mysql_query 问题

转载 作者:行者123 更新时间:2023-11-29 22:33:09 25 4
gpt4 key购买 nike

我有以下 PHP 代码:

$sql = '
SELECT t1.name, t2.code, COUNT(t2.code) as cnt
FROM t1
LEFT JOIN t2
ON t2.code = t1.code2
WHERE (t2.input_date BETWEEN "2015-04-01" AND "2015-04-29")
AND t2.serial = 5
GROUP BY t2.code HAVING (t2.code>0)';

$Chartdata= mysql_query($sql) or die(mysql_error());
$arr = array();
while ($row = mysql_fetch_assoc($Chartdata)) {
$arr[] = $row;
}
echo json_encode($arr);

此代码在我的浏览器上显示一个空白页面。我尝试删除最后一个“AND”和“GROUP BY...”,它显示1个值。

最佳答案

尝试一下:

$sql = '
SELECT t1.name, t2.code, COUNT(*) as cnt
FROM t1
LEFT JOIN t2
ON t2.code = t1.code2
WHERE (t2.input_date BETWEEN "2015-04-01" AND "2015-04-29")
AND t2.serial = 5
AND t2.code>0
GROUP BY t2.code';

关于PHP 和 mysql_query 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29659984/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com