Re: PAGING and hosts.php.net type search
| From: | Steve Edberg | Date: | Wed, 19 Jul 2000 17:18:06 +0000 |
| Subject: | Re: PAGING and hosts.php.net type search | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7318@lists.php.net to get a copy of this message | ||
At 12:55 AM -0700 7/19/00, Oleg Timofeyev wrote:
When searching on hosts.php.net results are all listed on one page. I was wondering how can you implement paging with structure like that. LIMIT $start,$max_per in query will not work because in order to calculate the score or how many times a particular listing matched the keywords searched for, one needs to retrieve all matching listing. What else is possible? You cant just store the listings you already displayed in array or a string and pass it page to page.Do two queries; the first simply is a 'SELECT COUNT(*) ...' to get the number of records, then the second query retrieves the actual records. You can then use the LIMIT clause on the second query. To avoid doing the count query _every_ time the page is hit (although a SELECT COUNT(*) is usually pretty fast), you could pass this count in a hidden var on your search page. If this hidden var isn't set, do the count. Otherwise, use the passed value. -steve +--- unix and cats: -----------------------------------------------------+
| Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu |+----------------------- hard to befriend, but then friends for life! ---+