-2
$d=array();
$e=array;

我有两个数据库列: $row['count']; $行['总计']; //while循环结束

$array=array($d,$e);
print_r($array);

表结构如下:

count   total
1         3
2         4

如何在循环外显示所有记录,因为它在循环内工作正常,但在循环外只显示最后一条记录?

4

2 回答 2

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);
于 2013-05-29T11:30:43.483 回答
0

试试喜欢

foreach($arr as $row)
    $my_arr[] = array($row['count']=>$row['total']);
于 2013-05-29T11:29:11.223 回答