Re: [GENERAL] Never ending (for) loop

From: "Dan Wilson" <dan_wilson(at)geocities(dot)com>
To: "Blks" <blake_star(at)email(dot)msn(dot)com>, <pgsql-general(at)hub(dot)org>
Subject: Re: [GENERAL] Never ending (for) loop
Date: 1999-08-18 02:03:16
Message-ID: 002f01bee91d$d71a48e0$6fc7fea9@dwilson
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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
>
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Lockhart 1999-08-18 06:34:41 Re: [HACKERS] getting at the actual int4 value of an abstime
Previous Message Ross J. Reedstrom 1999-08-17 23:24:55 Re: [HACKERS] getting at the actual int4 value of an abstime