title: How to fetch a row of data and store it in an array?
body: <p>I'm having trouble fetching data from my database and sorting it in an array.</p>
  
  <p>Here is my current code:</p>
  
  <p>I'm looping through each engine to create a sorted array with each servers ID. </p>
  
  <pre><code>for($i=0; $i &lt;= $servers_default_engines_count; $i++){
  
          //get all servers with this engine type, and get how many
          $query = $db-&gt;query("SELECT `id` FROM `cgshop_servers` WHERE `server_engine` = $i");
          $server_id = mysql_fetch_row($query);
  
          $server[$i] = array();  
          array_push($server[$i], $server_id); 
  
      };
  </code></pre>
  
  <p>Result with mysql_fetch_row:</p>
  
  <pre><code>    [0] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [0] =&gt; 2
                  )
          )
      [1] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [0] =&gt; 1
                  )
          )
  )
  </code></pre>
  
  <p>also:</p>
  
  <pre><code>[0] =&gt; Array
          (
          )
  
      [1] =&gt; Array
          (
          )
  
      [2] =&gt; Array
          (
              [0] =&gt; 1
          )
  </code></pre>
  
  <p>But i'm looking to return it like this:
  () placed for explanation reasons.</p>
  
  <pre><code>Array(
     [0] (engine1) =&gt; Array(
  
        [0](server1) =&gt; 2 (serverid)
     )
     [1(engine2)] =&gt; Array(
  
        [0](server1) =&gt; 1 (serverid)
        [1](server2) =&gt; 3 (serverid)
     )
  )
  </code></pre>
  
  <p>This is the current data in the mysql tables:
  cgshop_servers:</p>
  
  <pre><code>id   server_name   server_ip    serevr_port    server_engine    source_engine
  1    test1         195.62.14.65 15464          1                1
  2    test2         195.62.14.63 15464          0                0
  3    test3         195.64.14.62 15465          1                1
  </code></pre>