$d=array();
$e=array;
我有两个数据库列: $行[ '数']; $行[ '总']; // while循环结束
$array=array($d,$e);
print_r($array);
表结构如下:
count total
1 3
2 4
如何在循环外部显示所有记录,因为它在循环内工作正常但在外面只显示最后一条记录?
答案 0 :(得分:1)
尝试
while($row = $result->fetch_assoc())
$array[] = [$row['count'], $row['total'];
编辑:
$d=array();
$e=array();
while($rw =mysql_fetch_assoc($r)) {
$d[] = $rw['count1'];
$e[] = $rw['total'];
$array[] = array($rw['count1'], $rw['total']); // don't need this
}
$array=array($d,$e); // or that
print_r($array);
答案 1 :(得分:0)
尝试
foreach($arr as $row)
$my_arr[] = array($row['count']=>$row['total']);