I need to generate a dynamic table for an inventory program, for which I need a 2D array like this:
$quan[size_id][color_id]=quantity
The size_id and color_id values are 2-digit zerofill integers (05, 22, 37,etc), so i think things are getting confused with php's default numeric indexes. But I need to reference the quantity of a certain size or color like this:
$quan[05][34]
this is what I have to fill the array so far:
$result= mysql_query("select quantity, size_id, color_id from s_inventory
where product_id='$prod_id'");
while ($row=(mysql_fetch_array($result))) {
$size_id[]=$row["size_id"];
$color_id[]=$row["color_id"];
$quant_s[]=$row["quantity"];
}
for($f=0;$f<count($size);$f++){
$quan = array ($size_id[$f] => array ($color_id[$f]));
$quan[$f][$f]=$quant_s[$f];
}
needless to say, this doesn't work. Am I declaring the 2D array wrong? Should I rethink the whole thing with objects (and if so, how??)
Maybe I should use size and color names instead of ID's but that didn't really work either.
Thanks people!
-d