$d=array();
$e=array;
我有两个数据库列: $row['count']; $行['总计']; //while循环结束
$array=array($d,$e);
print_r($array);
表结构如下:
count total
1 3
2 4
如何在循环外显示所有记录,因为它在循环内工作正常,但在循环外只显示最后一条记录?
尝试
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);
试试喜欢
foreach($arr as $row)
$my_arr[] = array($row['count']=>$row['total']);