Hi All
This shouldn't be too hard, but I can't seem to dig up the answer.
I have quite a complex SQL query that I would like to use in different ways. The main objective is to loop through the results and display them nicely in a page.
One of the results of the query is the category that the db entry is assigned to (seperate table). I'd like to add the categories to a form which is outside of my while() loop. The reason for this would be so that I could have a pulldown menu that would allow people to limit the results based on the category.
I'm using pretty standard code to display the results. Obviously, I can only do the while loop on the results set once. I'm assuming php either clears it from memory after it's finished, or it has something to do with the array pointer being at the end of the array.
Lets say that this is my code for retrieving and displaying the results:
How would I go about accessing $sql in another loop without doing another mysql_query()?Code:$sql = mysql_query("SELECT * FROM foo_table"); while($result = mysql_fetch_array($sql)){ echo $result['id']; }
Can I?
Does this make sense?
Thanks
Marc






Bookmarks