Download Anime - Sxsy Lady Celebrity Fashion - Debt Consolidation - Debt Consolidation - Debt Consolidation

PDA

View Full Version : loop out the results from a mysql query in reverse order


relixx
Nov 13th 2006, 12:06 am
Man, I need more sleep. This is probably a very easy to solve solution, but for the life of me i cant figure it out

I have the results of a mysql query, and after its been used I need to loop through the results in the reverse order.

Im sure i could use a for statement, eg:

for ($i=5; $i>=0; $i--) {
find the row $i in the result
spit it out
}


however, i cant remember how to seek a specific row in mysql and my google searches arent turning p much (lol, i dont think im able to read the pages properly)

can somehow tell me how to go to a specific row in a result set? I used mysql_fetch_assoc, would i have to use another function?

streety
Nov 13th 2006, 12:20 am
mysql_fetch_assoc fetches just one row so presumably to do whatever you did to the result you would have extracted each row and put it in an array.

From there the for statement you have should work just fine.

relixx
Nov 13th 2006, 12:48 am
mysql_fetch_assoc fetches just one row so presumably to do whatever you did to the result you would have extracted each row and put it in an array.

From there the for statement you have should work just fine.

well, i actually dozed off at work and when i woke up it came to me in a flash of light (well, actually the flash of light was from my monitor going out of sleep mode, hahaha). mysql_data_seek was what i was trying to remember :)

drewbe121212
Nov 13th 2006, 1:03 am
Yeah; you have to remember that once it goes through the array, the cursor is in the last position.