"Apple","b"=>"Ball","c"=>"...">

How can I make this array data from a database?

How can I make this array with data from a database?

$array=array("a"=>"Apple","b"=>"Ball","c"=>"Cat"); 

I have a database table with letter and value columns.

 letter | value | a | Apple b | Ball c | Cat 

I want "a"=>"Apple","b"=>"Ball","c"=>"Cat" be a value from the database, using for a loop, how is this possible?

Thanks so much for any help!

+4
source share
1 answer

provided that you can complete the connection and select

 $array=array(); while ($row = mysql_fetch_assoc($result)) { $array[$row['letter']]=$row['value']; } print_r($array); 
+10
source

All Articles