mysqli_num_rows returns 1 no matter what

后端 未结 2 809
夕颜
夕颜 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条回答
  •  Happy的楠姐
    2020-12-02 01:56

    Count retrives a single row. Try testing the SQL in phpmyadmin and see the result. This single row returned by the query has the number you are looking for.

    I suggest also doing something like

    SELECT COUNT('user_id') AS user_matches FROM ....
    

    This way you can access the via the 'user_matches' key.

    *I would not recommend using SELECT * FROM ... * with the num_rows, this would be very slow compared to a count().

提交回复
热议问题