...

View Full Version : Pear DB. Seeking in a recordset.



Pompiuses
11-15-2003, 12:15 PM
I've got a recordset called $result. I want to collect records within a certain range in this recordset.

When I use the code below, it will display every two records as empty.
$start_write = 10;
$stop_write = 20;

for($i = $start_write;$i < $stop_write;$i++)
{
$row = $result->fetchRow($i);

$name = $row[0];
$email = $row[1];

echo "$name<br>$email<br><br>";
}


If I use this code all records are displayed correct:

while($row = $result->fetchRow())
{
$name = $row[0];
$email = $row[1];

echo "<br>$name<br>$email<br><br>";
}

Why won't fetchRow work properly with a parameter in my for-loop? Any way I can get around this?

Pompiuses
11-15-2003, 03:37 PM
Found the solution. Just had to set the fetchmode in fetchRow(). Like this:
$row = $result->fetchRow(DB_FETCHMODE_ORDERED, $i);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum