How to Reuse a MySQL Result Set CodeUnit 15 FEB 2011

To reuse an existing result set returned from a query is actually pretty simple thanks to PHP’s mysql_data_seek function and the fact that mysql_query returns a buffered result set by default.

So essentially all we want to do is rewind the entire pointer right to the start in order to reuse the set.

And to do this?

mysql_data_seek($result, 0);

Nifty.

About Craig Lotter

Software developer, husband and dad to two little girls. Writer behind An Exploring South African. I don't have time for myself any more.