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
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;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.