Jump to content

MYSQL result into one array


Gulsaes

Recommended Posts

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

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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.