我正在使用mysqli_query
SELECT COUNT( statid ) FROM device_realtime_stats
在此语句中,在db中返回一些值ex:3
我想在php中使用那个整数。我是这样给的
$rows_count = mysqli_query($con, " SELECT COUNT( statid ) FROM device_realtime_stats ");
但它不返回整数,如何转换。我希望PHP中的整数值
答案 0 :(得分:2)
你可以像这样计算
// this return mysqli statement not integer
$rows_count = mysqli_query($con, " SELECT COUNT( statid ) as count FROM device_realtime_stats ");
$count = mysqli_fetch_object($rows_count)->count; // return count as you want