You can call the mysql_data_seek() function to search for an arbitrary row in a result set.
Syntax
void
mysql_data_seek(MYSQL_RES *result,
my_ulonglong offset)
The offset value is a row number. Specify a value ranging from 0 to mysql_num_rows(result)-1.
Return values
None.
Errors
None.
Notes
This function requires that the result set structure contain the entire result of the query, so that mysql_data_seek() can be used only together with mysql_store_result(), rather than with mysql_use_result().