Man, I love Sp!ke's posts. He posts beautiful PHP code with excellent comments. Message to all--don't forget to use the post rating system to thank people who help you.
Ashneet, I think what you want is simply an array of arrays. PHP does not support true multi-dimensional arrays, but an array of arrays will fit the bill.
Put this code into a new PHP file and try it:
[PHP]
<?php
$items = array(
1=>array('name'=>'apple','color'=>'red','price'=>0.50)
,2=>array('name'=>'orange','color'=>'orange','price'=>0.60)
,3=>array('name'=>'banana','color'=>'yellow','price'=>0.35)
);
echo "";
print_r($items);
echo "";
?>
[/PHP]
Will output:
Array
(
[1] => Array
(
[name] => apple
[color] => red
[price] => 0.5
)
[2] => Array
(
[name] => orange
[color] => orange
[price] => 0.6
)
[3] => Array
(
[name] => banana
[color] => yellow
[price] => 0.35
)
)
So you can access individual items like so:
[PHP]
echo $items[2][color];
[/PHP]
Of course you would build your array dynamically from your database query.