Never ending (for) loop - Mailing list pgsql-general

From Blks
Subject Never ending (for) loop
Date
Msg-id 003e01bee8d2$7c324cc0$9c3efdd0@ibm
Whole thread Raw
List pgsql-general
I wanted to thank everyone who helped me witht he postgesql limit query. I
used the examples you fella's gave and they worked great. Thanks again.

How would I quite the for loop however? If I have only 103 rows in a table,
how do I get the for loop to stop cycling through? any suggestions are
greatly appreciated.

<SCRIPT language="PHP">

if (!isset($iStart)) {
    $iStart = 0;
}
if (!isset($iEnd)) {
    $iEnd = $iStart + 10;
}

$conn = pg_Connect("", "", "", "", "contact_list");
if (!$conn) {
  echo "An error occurred.\n";
  exit;
}

$result = pg_Exec($conn, "SELECT * FROM contact_list");
if (!$result) {
    echo "An error occurred.\n";
    exit;
}

for ($iWalk = $iStart; $iWalk < $iEnd; $iWalk++) {
    $resArray = pg_fetch_array($result, $iWalk);
    echo "<TR>
            <TD>
            $resArray[2]
            </TD>
            <TD>
            $resArray[3]
            </TD>
            <TD>
            $resArray[4]
            </TD>
            <TD>
            $resArray[6]
            </TD>
            <TD>
            $resArray[1]
            </TD>
            <TD>
            $resArray[0]
            </TD>
            <TD>
            <center>
            $resArray[8]
            </center>
            </TD>
        </TR>
        ";
}

echo "<a href=\"$PHP_SELF?iStart=$iEnd\">Next 10</a>";

pg_FreeResult($result);
pg_Close($conn);
</script>

Thank You,
Blake S




pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [GENERAL] Large database
Next
From: jim@reptiles.org (Jim Mercer)
Date:
Subject: Re: [GENERAL] Large database