我想将SQL COUNT的结果存储在变量中,然后将它们除,但是出现错误:
注意:类mysqli_result的对象无法在----中转换为int
$countrows = 'SELECT count(*) AS NumRows FROM time_slots'; $countresult = $db->query($countrows); $something = $countresult/3 ; echo $something;
我曾经echo在测试时显示结果…我该如何解决?
echo
您需要先获取结果并将其存储在变量中,然后再进行数学运算。
countrows = 'SELECT count(*) AS NumRows FROM time_slots'; $countresult = $db->query($countrows); $count = $countresult->fetch_assoc(); $something = $count['NumRows']/3 ; echo $something;