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. Quote Link to comment 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... Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
shahzad429 Posted February 24, 2011 Author Share Posted February 24, 2011 Thankyou Thankyou ManiacDan its worked perfect.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.