简体   繁体   中英

How to get value from mysqli_query

I am using mysqli_query

SELECT COUNT( statid ) FROM device_realtime_stats

In this statement, in db returns some value ex:3

I want to that integer in php. I am giving like this

$rows_count = mysqli_query($con, " SELECT COUNT( statid ) FROM device_realtime_stats ");

But it not returns integer, how to convert. I want that integer value in PHP

you can get count like this

// 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM