From: | "Blake Starkenburg" <blake_star(at)email(dot)msn(dot)com> |
---|---|
To: | <pgsql-general(at)hub(dot)org> |
Subject: | Limit postgresql query results |
Date: | 1999-08-16 16:34:32 |
Message-ID: | 025e01bee805$38b02120$ef3efdd0@ibm |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello, I am using PostgreSQL 6.3 and PHP. I am trying to build a query that
only returns 20 results at a time, with a "next" link at the bottom of the
query results for the next 20. Someone suggested to me that I use the below
block of code (pg_Exec ($conn, "set QUERY_LIMIT='20'");). How would I use
this in the below code I'm already using to connect to and query the DB? And
does anyone maybe have any better ideas of going about this task?
CODE I WAS GIVEN TO USE
---------------------------------------------------------------------
pg_Exec ($conn, "set QUERY_LIMIT='20'");
---------------------------------------------------------------------
THE CODE I AM USING NOW
---------------------------------------------------------------------
<SCRIPT language="PHP">
$conn = pg_Connect("Localhost", "5432", "", "", "contacts");
if (!$conn) {
echo "An error occurred.\n";
exit;
}
$result = pg_Exec($conn, "SELECT* FROM contacts_list");
if (!$result) {
echo "An error occurred.\n";
exit;
}
$num = pg_NumRows($result);
$i = 0;
while ($i < $num) {
echo "<TR><TD><font>";
echo pg_Result($result, $i, "personal_id");
echo "</font></TD><TD><font>";
echo pg_Result($result, $i, "name");
echo "</font></TD><TD><font>";
echo pg_Result($result, $i, "address");
echo "</font></TD><TD><font>";
echo pg_Result($result, $i, "city");
echo "</font></TD><TD><font>";
echo pg_Result($result, $i, "state");
echo "</font></TD><TD><font>";
echo pg_Result($result, $i, "zip_code");
echo "</font></center></TD><TD><center><font>";
echo pg_Result($result, $i, "phone_number");
echo "</font></center></TD></TR>";
$i++;
}
pg_FreeResult($result);
pg_Close($conn);
</script>
---------------------------------------------------------------------
Thank you everyone for your help
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 1999-08-16 16:45:32 | Re: [GENERAL] FATAL 1: my bits moved right off the end of the world! |
Previous Message | Geocrawler.com | 1999-08-16 15:45:43 | Newbie - Inserting Images |