gpt4 book ai didi

php - MySQL排名如果为空则显示空白页

转载 作者:行者123 更新时间:2023-11-28 01:26:24 25 4
gpt4 key购买 nike

我有一个按天显示前 5 名卖家的查询,如果我想在工作日查看该页面,它会起作用,因为我在今天日期之前在表格中有元素,但如果我在星期天查看该页面,我得到一个完整的白页

有没有办法不要得到这个白页?

这里是卖家top 5 position 3的例子

PHP

$datum=date('Y-m-d');

数据库

$tredje= mysqli_query($datacenter, "
SELECT vendedor, total,
CASE WHEN @l=total THEN @r
ELSE @r:=@r+1 END as rank,
@l:=total FROM (select vendedor,
sum(ventatotal) as total
from ventas WHERE `fecha` = '$datum'
group by vendedor
order by total desc
LIMIT 7 OFFSET 2
) totals, (SELECT @r:=0, @l:=NULL) rank;");

要显示的 PHP

while($dentredje = mysqli_fetch_assoc($tredje))
{
?>
<?php echo number_format($dentredje['total'],0,',','.'); ?>

这是查询

最佳答案

if($dentredje)
{
while($dentredje = mysqli_fetch_assoc($tredje))
{
echo number_format($dentredje['total'],0,',','.');
}
}
else
{
echo "your Sunday message here.";
}

关于php - MySQL排名如果为空则显示空白页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51219391/

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