我有一个查询,可以按日显示前5名卖家,如果我想在一个工作日内查看该页面,则可以使用该查询,因为我在今天这一天之前的表中都有商品,但是如果我在星期日查看该页面,得到整个白页
有没有办法获取此白页?
下面是卖方排名前5位的示例
PHP
$datum=date('Y-m-d');
MYSQL
$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,',','.'); ?>
这是查询
答案 0 :(得分:0)
if($dentredje)
{
while($dentredje = mysqli_fetch_assoc($tredje))
{
echo number_format($dentredje['total'],0,',','.');
}
}
else
{
echo "your Sunday message here.";
}