On Fri, Apr 06, 2001 at 02:15:34PM +0300, Dainius Vaskelis wrote:
> I suppose that you are using MySQL (because of LIMIT operator in SQL query)
I m using PostgreSql
> So:
> > In the second query i write a query whereby i say
> > $result=pg_Exec($database,"SELECT mem_id,name from search LIMIT $count");
> > Now here i display the the first 10(say $count=10) records.
> > Now I know to display the other records i can say
> > $result=pg_Exec($database,"SELECT mem_id,name from search LIMIT
> $count,$count");
> > but what condition to give to display pages of more than $count records
> > i.e how do i give for next existing page.
>
> LIMIT operator has two parameters: amount of records of result, offset in
> result.
>
> So in order to paginate your output you need such scheme:
>
> $count = 10;
> $offset = 0;
> <loop begin>
> ...
> $result=pg_Exec($database,"SELECT mem_id,name from search LIMIT
> $count,$offset");
> $offset += $count;
> ...
> <loop end>
What shall the loop be like,i mean the condition for terminating the search.
> If you want to use this to make output as search engines do (output first 10
> recs on the first page, and output links of other pages), so you need to
> modify a litle bit. You need to pass by parameters page no, in other pages
> link:
>
> $count = 10;
> $offset = 0
> if is_set(page_no) {
> $offset = $page_no * $count;
> }
>
What is page_no here and doesn't $offset get overidden here
> ...
> $result=pg_Exec($database,"SELECT mem_id,name from search LIMIT
> $count,$offset");
> ...
>
> Hope it'll help you. Good luck.
I was of great help but i want more help or URL or atleast a practical reference on
this.
Pls if possible look at the forms
Regards,
--
The secret of the universe is @*&í!'ñ^#+ NO CARRIER
__ _ _ _ _
|_|_||_||_||\/||_|| \
_|| || || \| || ||_/
<HTML>
<BODY>
<?php
echo("$mem_id \n");
$count=10;
$offset=0;
$database=pg_connect("dbname=search user=pro");
if is_set(page_no)
{
$offset=$page_no*$count;
}
while(echo("<INPUT TYPE=SUBMIT VALUE=Submit NAME=Submit>");){
$result=pg_Exec($database,"SELECT * from search ".
"where acc_no='$mem_id' LIMIT $count,$offset");
for ( $i=0 ; $i < pg_NumRows($result) ;$i++)
{
echo pg_Result($result,$i,0);echo"\t";
echo pg_Result($result,$i,1);echo"\t";
echo pg_Result($result,$i,2);echo"\t";
echo pg_Result($result,$i,3);echo"\t";
echo "<BR>";
}
$offset+=$count;
}
?>
</BODY>
</HTML>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]