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?

Upvotes: 0

Views: 185

Answers (1)

user4670949
user4670949

Reputation:

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.

Upvotes: 2

Related Questions