gpt4 book ai didi

php - 如何在 mysqli_fetch_object 中获取计数帮助我

转载 作者:太空宇宙 更新时间:2023-11-03 11:44:07 24 4
gpt4 key购买 nike

echo $getq2 = "SELECT publisher,COUNT(publisher) from (select publisher from wiley where $getq2_ UNION ALL SELECT publisher FROM elsevier WHERE $getq2_ UNION ALL SELECT publisher FROM sage WHERE $getq2_  UNION ALL SELECT publisher FROM indianjournal WHERE $getq2_) as publisher Group by publisher order by publisher";

$getquery1 = $conn->query($getq2);

通过查询获取之后

while($runrows =mysqli_fetch_object($getquery1))
{
print_r($getquery1);

echo $pub=$runrows->publisher;
//getting the publisher list
echo $count=$runrows->count['publisher'];
//not grtting the publisher count
}

我得到了发布者,但没有得到计数。我怎样才能得到计数?

最佳答案

根据您的查询,您可以这样获取

$runrows->COUNT(publisher);  

或将查询更改为 .像这样设置别名 COUNT(publisher) as count

echo $getq2 = "SELECT publisher,COUNT(publisher) as count from (select publisher from wiley where $getq2_ UNION ALL SELECT publisher FROM elsevier WHERE $getq2_ UNION ALL SELECT publisher FROM sage WHERE $getq2_  UNION ALL SELECT publisher FROM indianjournal WHERE $getq2_) as publisher Group by publisher order by publisher";

然后像这样

 $runrows->count; 

关于php - 如何在 mysqli_fetch_object 中获取计数帮助我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39825441/

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