putting mysql query into array and using more than once error
<p>I have a real big problem that normally doesn't happen. For some reason on this occasion it errors...</p>

<p>Ok I put in a mysql query IE </p>

<pre><code>$query = mysql_query("SELECT * from tablename");
</code></pre>

<p>Then i say</p>

<pre><code>$row = mysql_fetch_array($query,MYSQL_BOTH)
</code></pre>

<p>When I put (even a blank loop in it gives me an error) a loop in... 
IE</p>

<pre><code>foreach ($row as $rowme){
 // do nothing
   echo $rowme['id'] . "&lt;br /&gt;";
}
</code></pre>

<p>I get invalid argument supplied for foreach()</p>

<p>Never before has this happened - any ideas why it is now?</p>

<p>Running PHP 5.2.11 on the server</p>

<p><code>while($row = mysql_fetch_assoc)</code> = works fine, but I can use this only once on the page... another question why can't I use the same loop again somewhere else? (Coldfusion you can use the same loop from a query repeatedly? why does not PHP do this using <code>mysql_fetch_assoc</code>???)</p>

<p>I'm using a jQuery photo gallery, which populates some repeated javascript to write the descriptions on the images via the class and repeats the list items they are in, hence I need two loops of the same query. So obviously putting the query results into an array and using the array repeatedly should work right?</p>

<p>The only other option is to create two queries exactly the same. Seems inefficient however.</p>

<p>Can anyone answer these questions or shed some light. I'm desperate and very very behind putting in this gallery, (why I'm still here at work at 1.22 am) - Would be most grateful.</p>

<p>Thanks</p>

<p>A.</p>
