Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have retrieve some data from table. form array like

enter image description here

I want array is..

 $subpro[HardDisk] = array (H1000 => 1200,H500 => 700);
    $subpro[Ip] = array (4IP => 400 , 2IP => 200);
    $subpro[Ram] = array (..);
    $subpro[processor] = array (...);

php code ..

while($row=mysql_fetch_array($res))
    {
        if(sizeof($subpro[$row['category']]>0) 
array_put_to_position($subpro[$row['category']],$row['rate'], 2,$row['name']);
        else
                        $subpro[$row['category']]=array($row['name']=>$row['rate']);                
    }
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Unless I've misunderstood the question the answer is pretty simple.

$subpro = array();
while($row = mysql_fetch_array($res)) {
  $subpro[$row['category']][$row['name']] = $row['rate'];
}
share|improve this answer
    
I have finished it.. thanks for your response.. your answer is correct.. but i finished before submit your answer –  jey Jul 4 '12 at 12:13
    
You haven't provided the answer on your question - therefore you should accept this as the answer. This will help other people find the answers they need on the site. Your 50% accept rate is quite low - you should fix this. –  LeonardChallis Jul 4 '12 at 12:51
    
ok.. i accepted –  jey Jul 5 '12 at 6:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.