Log in

View Full Version : Resolved multidimensional array from loop



ggalan
02-11-2012, 12:00 AM
ive always had issues with arrays. can anyone help out how to push 2 values into an array so that i can echo them later please?


$arr = array();

$query0 = "SELECT navid, type FROM mytable WHERE id='$id' ORDER BY navDisplayNum ASC";
$result0 = mysql_query($query0) or die (mysql_error());

while ($dataList = mysql_fetch_assoc($result0)) {
$navid = $dataList['navid'];
$type = $dataList['type'];

$arr[] = array($type,$navid);// this doesnt work

}
echo $arr;

fastsol1
02-11-2012, 12:10 AM
That looks like that should work. But using echo on the $arr is wrong, you need to use print_r() if you want to see what the array holds.