mysqli_num_rows returns 1 no matter what

后端 未结 2 814
夕颜
夕颜 2020-12-02 01:19

When I do a SQL search in phpMyAdmin (substituting the variable for the actual value) it returns the correct row number but when using PHP to return this value it always ret

2条回答
  •  长情又很酷
    2020-12-02 01:58

    When you use COUNT(*) you always get one row returned even if the count is zero.

    You either:

    1. Want to remove the count(*) and then use mysqli_num_rows() or
    2. Get the result of count(*)

    .

    $row = mysqli_fetch_assoc($query);
    echo $row['COUNT(`user_id`)'];
    

提交回复
热议问题