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

Ok I put in a mysql query IE $query = mysql_query("SELECT * from tablename");
Then i say $row = mysql_fetch_array($query,MYSQL_BOTH)
When I put (even a blank loop in it gives me an error) a loop in... 
IE
foreach ($row as $rowme){
 // do nothing
   echo $rowme['id'] . "<br />";
}

I get invalid argument supplied for foreach() .... ????? WTF ???? Never before has this happened... running PHP 5.2.11 on the clients server... Wanted a higher version but that's all they'll let us run, so got to make do..

while($row = mysql_fetch_assoc) = 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 mysql_fetch_assoc???)

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

The only other option is to create two queries exactly the same, but that seems well pants!

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.

Thanks

A.





putting mysql query into array and using more than once error
===

I have a real big problem that normally doesn't happen. For some reason on this occasion it errors...

Ok I put in a mysql query IE $query = mysql_query("SELECT * from tablename");
Then i say $row = mysql_fetch_array($query,MYSQL_BOTH)
When I put (even a blank loop in it gives me an error) a loop in... 
IE
foreach ($row as $rowme){
 // do nothing
   echo $rowme['id'] . "<br />";
}

I get invalid argument supplied for foreach() .... ????? WTF ???? Never before has this happened... running PHP 5.2.11 on the clients server... Wanted a higher version but that's all they'll let us run, so got to make do..

while($row = mysql_fetch_assoc) = 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 mysql_fetch_assoc???)

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

The only other option is to create two queries exactly the same, but that seems well pants!

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.

Thanks

A.




