simplified: mysqli num_rows not working

后端 未结 1 1418
栀梦
栀梦 2020-12-21 14:15

How do I output the number of returned rows using mysqli? My code below shows 0 though a while loop (while $s->fetch() echo $uid;) shows 2 results;

$m = new          


        
相关标签:
1条回答
  • 2020-12-21 15:15

    You'll have to call mysqli_stmt::store_result() after mysqli_stmt::execute() and before fetch in order to know mysqli_stmt::num_rows:

    $s->execute();
    $s->store_result();
    print_r($s->num_rows);
    

    PHP Document on num_rows

    PHP Document on store_result()

    0 讨论(0)
提交回复
热议问题