Re: [GENERAL] Never ending (for) loop - Mailing list pgsql-general

From Dan Wilson
Subject Re: [GENERAL] Never ending (for) loop
Date
Msg-id 002f01bee91d$d71a48e0$6fc7fea9@dwilson
Whole thread Raw
In response to Never ending (for) loop  ("Blks" <blake_star@email.msn.com>)
List pgsql-general
If you are using the code below.  It should stop at $iEnd.  If it's the
first time through, it would stop at 10.

-Dan


> 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: "Ross J. Reedstrom"
Date:
Subject: Re: [HACKERS] getting at the actual int4 value of an abstime
Next
From: Thomas Lockhart
Date:
Subject: Re: [HACKERS] getting at the actual int4 value of an abstime