Never ending (for) loop

From: "Blks" <blake_star(at)email(dot)msn(dot)com>
To: <pgsql-general(at)hub(dot)org>
Subject: Never ending (for) loop
Date: 1999-08-17 17:03:52
Message-ID: 003e01bee8d2$7c324cc0$9c3efdd0@ibm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 1999-08-17 17:03:54 Re: [GENERAL] Large database
Previous Message jeremy 1999-08-17 16:44:44 oh micky