简体   繁体   中英

Mysqli count not working properly

$sql = "SELECT count(id),soft_name from table_name GROUP BY soft_name"; 
$d = mysqli_fetch_assoc(mysqli_query($db_name, $sql));
$c = array_shift($d);

The result is always 2, but the database contains more than 3000 items. What could be the problem?

Records are not pulled the way you are pulling for that you have to use similar to following code:

if($result = mysqli_query($db_name, $sql)){
    while($d = mysqli_fetch_assoc($result){
         echo $d['count'];
    }
 }

More reference here .

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