views:

722

answers:

2

I've got a fairly standard while mysql_fetch_array statement in php, and I'm trying to figure out which row in the result set is being printed.

I figured this should be pretty simple, but I've put a fairly standard

$i=0;
$count=mysql_num_rows($getResults);
while($resultArray=mysql_fetch_array($getResults)){

$i++
if($i==$count){
echo "this is the last row";
}
}

but strangely, that isn't working. is there another way to find the last row?

+1  A: 

What you've got is correct (that is, it should be working): are you sure that there are more than 0 rows being returned?

nickf
Yup, more than 0 rows being returned, but I had screwed up my loop, so that last bit was running outside of the while loop.Sorry about that, my bad.
pedalpete
+1  A: 

This worked for me. Your placement was a little different and you didnt have a semi-colon after $i++

$i=0;
$count=mysql_num_rows($result);
while($resultArray=mysql_fetch_array($result))
{
    if($i==$count-1)
    {
        "this is the last row";
    }
    $i++;
}
Samuel
sorry yours worked fine, id check your query string
Samuel