title: PHP - Storing mysql_fetch_assoc in a multi-dimensional array
body: <p>I'm new to PHP, so I'm not exactly sure how it works.</p>
  
  <p>Anyway, I would line to return a multidimensional array to another method, essentially something storing a small amount of record and columns, table like structure.</p>
  
  <p>I've written the following, no warning but no data either</p>
  
  <pre><code>public function GetData($sqlquery)
  {
      include 'config.php';
  
      $result = mysql_query($sqlquery,$con);
      $data = array();
  
      while($row = mysql_fetch_assoc($result))
      {
          $data[] = $row;
      }
  
      return $data;
  }
  </code></pre>
  
  <p>Most likely doing something stupid</p>
  
  <p>Help appreciated.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Thanks for all the fast replies</p>
  
  <p>I figured out why this wasn't working, I was addressing the array as such</p>
  
  <pre><code>print $data[0][0];
  </code></pre>
  
  <p>Rather than</p>
  
  <pre><code>print $data[0]['title']; 
  </code></pre>
  
  <p>for example, thanks all :)</p>
  
  <p>PS I really find it hard to believe you can't say $data[0][5], It's more logical IMO than specifying a string value for location</p>