$qst_id = $_GET['str'];
if ($qst_id) {
$qst_sql = "SELECT * FROM exam_qst WHERE qst_id='$qst_id'";
$query = $conn -> query($qst_sql);
$row = $query -> fetch_array();
$length = sizeof($row)/5;
$a = 0;
while ($a < $length) {
$i = 0;
echo "<tr>";
while ( $i< 5) {
$j = $i++;
echo "<td>$row[$j]</td>";
}
echo "</tr>";
$a++;
}
$query -> close();
}
$conn -> close();
如代码,每次查询数据库应该取出多行数据,但是mysqli_fetch_array跟mysqli_fetch_row似乎都只能返回一行数据。请问如何能将查询到的所有数据全部装到一个数组里。
确实是需要遍历所有的结果集,自己用foreach来执行并成功返回了。还是谢谢 @捞鱼的转阿转