multidimensional array problem
Posted: Tue Dec 15, 2009 5:51 pm
hey there
i have a db table that has groups of characteristics and characteristics ids and in another the values of these characteristics
so i want to have in the end an $array[groupOfchar][char][value0fchar];
like car[equip][comfort][ac]=>yes
or car[specs][ perfomance ][0-100]=>4.5 or
or car[specs][ perfomance ][max-speed]=>220
i try to print it like that:
//im not really comf in using arrays
//going for the two dimensions
i get WRONG data !
thnx
i have a db table that has groups of characteristics and characteristics ids and in another the values of these characteristics
so i want to have in the end an $array[groupOfchar][char][value0fchar];
like car[equip][comfort][ac]=>yes
or car[specs][ perfomance ][0-100]=>4.5 or
or car[specs][ perfomance ][max-speed]=>220
i try to print it like that:
//im not really comf in using arrays
//going for the two dimensions
Code: Select all
$queryL1 = "SELECT * FROM tree WHERE level='1' ";
$editions=array();
$query=mysql_query($queryL1);
while($array=mysql_fetch_array($query)){
$editions[]=$array["name"];
foreach ($editions as $key=>$k ){
$queryL2 = "SELECT * FROM tree WHERE assign='$k' ";//so far so good
$L2=array();
$quer=mysql_query($queryL2);
$array2=mysql_fetch_array($quer);
$L2[]=$array2["name"];
foreach ($L2 as $key2=>$v ){
$L2[]=$array2["name"];
}print " Level 1 " . $k ." Level2 -".$v. "<BR>";
}
}
print_r($L2);thnx