Converting php mysql results into an array
<p>I have got this function:</p>

<pre><code>    public function get_all_sites($niche){
    $query="SELECT * 
           FROM sites AS site
           INNER JOIN niche AS n ON n.niche_id=site.niche_id
           INNER JOIN review AS r ON r.site_id=site.site_id
           WHERE n.niche_id=".$niche;
    $results=mysql_query($query) or die(mysql_error());

  while($rows[] = mysql_fetch_assoc($results));

    return $rows;
}
</code></pre>

<p>What i want to do is to convert all the rows into an associative array in one go and return it. Since there are many values returned, I dont want to use any push functions or write code like this $new_array['id']=$row['id'];. A shorter code is better.</p>

<p>Okay, the connection error is gone. How can I output get all the rows as an array out of mysql_fetch_assoc without fetching the results from inside the loop</p>
