Re: using LIMIT

From: Date: Sun, 08 Apr 2001 05:09:04 +0000
Subject: Re: using LIMIT
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8348@lists.php.net to get a copy of this message
Hello Sharmad, On 06-Apr-01 08:33:54, you wrote: >Hi, > Thanks for firstly helping me out with the prevoius query. > I have a database with mem_id(int) and name(text) as its fields. > In the first form (HTML) ,I take mem_id,name and count(used for LIMIT) > from the browser. > 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. What you need to do is to pass to the LIMIT clause the $first and $limit values where the $first is the number of the page of results you want to display times the number records you want to see per page which is also the $limit. Maybe you want to look at Metabase which is a PHP database abstraction page that lets you specify the range of rows that you want to retrieve pretty much like the LIMIT clause, except that it works well in all supported databases including PostgreSQL versions that did not support the LIMIT clause. http://phpclasses.UpperDesign.com/browse.html/package/20 With Metabase you may use this other PHP query result table display class that is able to display query result rows in HTML tables with optional links to go to the next, previous, first, last, etc... result pages. It uses MetabaseSetSelectedRowRange($database,$first,$limit) function to choose the rows that it displays in each page. Regards, Manuel Lemos Web Programming Components using PHP Classes. Look at: http://phpclasses.UpperDesign.com/?user=mlemos@acm.org -- E-mail: mlemos@acm.org URL: http://www.mlemos.e-na.net/ PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp --

« previous php.db (#8348) next »