I wrote a system for managing polls recently, and decided to store the userID of the person who voted in the poll in a users_voted char field in the poll answers table. I did it this way to easily match the user with their answer in the poll.
Anyways, when I'm looping through the poll answers I want to check whether the user viewing the page has already voted in the poll and, if they haven't voted already, show a radio button so they can. The problem is that you don't know if a user has voted until the loop gets to the poll answer they voted for. My workaround for this was to loop through the poll answers twice, the first time just getting the user IDs and the second time doing everything else. This seems like a pretty clumsy solution because the only way I could make php loop through the poll answers twice was to query the data twice, which is inefficient.
Which brings me to my question. What does php do with mysql_query() that prevents you from creating two array sout of the same query? I tried copying the sql handle returned from mysql_query() to use with mysql_fetch_array() twice but that didn't work either. Any ideas on looping through the same mysql_fetch'ed array twice without selecting the data twice?