Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pear DB. Seeking in a recordset.

    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?
    Last edited by Pompiuses; 11-15-2003 at 03:01 PM.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Found the solution. Just had to set the fetchmode in fetchRow(). Like this:
    $row = $result->fetchRow(DB_FETCHMODE_ORDERED, $i);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •