mysqli query only returning first row

前端 未结 5 2107
不思量自难忘°
不思量自难忘° 2020-12-12 03:16

I am migrating from mysql to mysqli, and I am having trouble returning more than one row from the database in a query.

$db = new mysqli($hostname, $sql_us, $         


        
5条回答
  •  没有蜡笔的小新
    2020-12-12 03:22

    You need to store while loop values into array try this

    $rows = array();
    if ($type == 'assoc') {
        while($row = $result->fetch_assoc()) {
          $rows[] = $row;
        }
    } else {    
        while($row = $result->fetch_object()) {
          $rows[] = $row;
        }   
    }
    return $rows;
    

提交回复
热议问题