If you're asking how it could be done without using mysql_data_seek(), you could build an array of arrays, index the "top level" one by usergroupid, and each element of that would be another array containing any data you need (or just store the row array). Then when you're done you could use a loop similar to what you have, but go through the array you built.
If you're asking if that's a better idea than what you have, I don't know. My gut feeling is that unless your query is very big, it won't make much difference. But I'm not sure.
Edit: Oh, actually if you add an "ORDER BY" clause to your query, you should be able to produce the same output with one pass through the data, you just have to save the previous groupid so you can output a new header when it changes.
|