Gulsaes Posted November 19, 2008 Share Posted November 19, 2008 I currently have $SADC_ARRAY=array('STATION1','STATION3','STATION2'); when printing it out i get Array ( [0] => FAJS [1] => FAJB [2] => FALA [3] => FAWB) since my list is growing i have moved this array to mysql database But i dont have a clue how to get all the results of the Mysql query stored into $SADC_ARRAY similar to what returns with the above code. $query = "SELECT icao_code FROM stations ORDER BY region DESC"; $result = mysql_query($query); for ($i = 0; $row = mysql_fetch_row($result); $i++) { $result_array[$i] = $row; } return $result_array; But I dont seem to get the same result when i print the array it returns Array ( [0] => Array ( [0] => STATION1 ) [1] => Array ( [0] => STATION2 ) [2] => Array ( [0] => STATION3 ) [3] => Array ( [0] => STATION4) [4] => etc Any help would be greatly appreciated thanks in advance. Link to comment https://forums.phpfreaks.com/topic/133315-mysql-result-into-one-array/ Share on other sites More sharing options...
Mchl Posted November 19, 2008 Share Posted November 19, 2008 I think you want it this way $query = "SELECT icao_code FROM stations ORDER BY region DESC"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $result_array[] = $row['icao_code']; } return $result_array; Link to comment https://forums.phpfreaks.com/topic/133315-mysql-result-into-one-array/#findComment-693325 Share on other sites More sharing options...
Gulsaes Posted November 19, 2008 Author Share Posted November 19, 2008 awesome that works, I always get confused with for and while Thanks A million!!! (anyone invented a Big Red Button for coding? they would make a killing) Link to comment https://forums.phpfreaks.com/topic/133315-mysql-result-into-one-array/#findComment-693326 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.