shahzad429 Posted February 24, 2011 Share Posted February 24, 2011 $items = array("Great Bittern"=>"Botaurus stellaris", "Little Grebe"=>"Tachybaptus ruficollis", "Heuglin's Gull"=>"Larus heuglini"); above is the sample of manual array in which key and value is entered manually. But now i want to have same structure of array but values need to come from mysql database. thanks in advance. Link to comment https://forums.phpfreaks.com/topic/228696-php-array-help-needed/ Share on other sites More sharing options...
cs.punk Posted February 24, 2011 Share Posted February 24, 2011 Huh what? I think you need to be more clear on what you are trying to do... Link to comment https://forums.phpfreaks.com/topic/228696-php-array-help-needed/#findComment-1179079 Share on other sites More sharing options...
ManiacDan Posted February 24, 2011 Share Posted February 24, 2011 $rs = mysql_query("SELECT key, value FROM table1"); while ( $row = mysql_fetch_array( $rs ) ) { $array[$row['key']] = $row['value']; } Setting up the table and cleaning up this code is left up to the reader. -Dan Link to comment https://forums.phpfreaks.com/topic/228696-php-array-help-needed/#findComment-1179083 Share on other sites More sharing options...
shahzad429 Posted February 24, 2011 Author Share Posted February 24, 2011 Thankyou Thankyou ManiacDan its worked perfect.. Link to comment https://forums.phpfreaks.com/topic/228696-php-array-help-needed/#findComment-1179085 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.