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

Recommended Answers

All 4 Replies

Member Avatar for 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 for 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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.