Table's name: grandTotal
(have two fields :defect_code and total)

defect_code total
LM 23
FM 15
DF 5

How this data can be an array like this
array("LM" >=23, "FM">=15,"DF">=5) using query? please help me..:S

Member Avatar

diafol

...

while($row = mysql_fetch_array($result)){
  $myarray[$row['defect_code']] = $row['total']; 
}
//check with:
print_r($myarray);

This should work:

<?php
# ...
# connection code
# ...

$q = mysql_query('select defect_code, total from grandTotal');
$a = array();
while($row = mysql_fetch_object($q))
{
    $a[$row->defect_code] = $row->total;
}

print_r($a); # display array
?>

bye :)

ooops ardav, I just saw your reply, sorry.. :D

Member Avatar

diafol

Aha, cereal you OOPed it. Nice. :)

Table's name: grandTotal
(have two fields :defect_code and total)

defect_code total
LM 23
FM 15
DF 5

How this data can be an array like this
array("LM" >=23, "FM">=15,"DF">=5) using query? please help me..:S

Thanks!! really appreciate