Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001041

Re: [PHP-DB] using LIMIT From: Sharmad Naik (sharmad <email protected>)
Date: 04/07/01

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
__    _  _      _  _
|_|_||_||_||\/||_|| \
_|| || || \|  || ||_/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>