mysql_query() resultset internal pointer<

Is there a way to know when you're on the first "row" of a mysql_query() resultset?

For instance I have this code (as per the usual) :

while($row = mysql_fetch_row($results)) {
list($whatever, $another_var) = $row;
// some more actions
}

Now, the hitch: if we're on the first row of the resultset ($result in the example) I want to do something special that I don't want to do for the rest of the set. I was searching for a way to do it using PHP functions and could find it. Is there a way.

FYI: the question is an acadeic one. I've already solve the problem by setting a flag true outside the while loop and then the beginning of the loop reads:

if($flag) {
$flag=false;
// do actions
}

That way my actions are performed once and only once for the first row of the resultset.

Anyway, any way to do it using mysql_xxxxx() functions or the like?I think the mysql_data_seek() function might help you, here is the manual link...

<!-- m --><a class="postlink" href="http://uk2.php.net/mysql_data_seek">http://uk2.php.net/mysql_data_seek</a><!-- m -->
 
Back
Top