MySQL internal row pointer.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

MySQL internal row pointer.

Post by JellyFish »

I have a situation where I need to get the index of the internal row pointer in a loop.

Code: Select all

 
while ($row = mysql_fetch_array($result))
{
if (mysql_get_row_pointer() == 0)
{
 
}
}
 
I'm looking for a function like mysql_get_row_pointer(fake function) that should return the index number of the internal row pointer. This way I could do something on the first iteration of the loop.

I tried looking for a mysql function like the above but no luck. :(

I'm sure someone has come across this type of problem?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: MySQL internal row pointer.

Post by Benjamin »

Code: Select all

 
$x = 0;
 
while ($row = mysql_fetch_array($result))
{
    if ($x == 0) { /* do something */ }
    $x++'
}
 
 
?
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Re: MySQL internal row pointer.

Post by JellyFish »

Oh right. Now I feel a bit dumb. I could use a for loop instead of a while loop.

But I guess why I was posting this is because I was looking for a function that returns the internal row pointer or something.

Anyway, thanks a bunch!
Post Reply