-1
 do {
$pet_name = $row['pet_called'];

$ary = array($pet_name);

}while($row_pet = mysql_fetch_assoc($pet));

When called it must display the value, which can be done by the for loop etc.

echo $ary[0..x];

This is not working and how do i get to do this?

4

2 回答 2

2
$ary = array();
while ($row = mysql_fetch_assoc($pet)) { 
    $ary[] = $row['pet_called'];
}

$ary[] = ...是将元素添加到数组的语法。

于 2013-05-12T08:34:33.617 回答
0

不要使用do...while. $row在第一次迭代中不会设置任何内容。这就是为什么它不起作用。尝试一下while

$ary = array();
while($row_pet = mysql_fetch_assoc($pet))
{
$ary[] = $row_pet['pet_called'];
}
于 2013-05-12T08:30:35.530 回答