RE: [PHP] PAGING and hosts.php.net type search
| From: | LISTS | Date: | Wed, 19 Jul 2000 19:27:12 +0000 |
| Subject: | RE: [PHP] PAGING and hosts.php.net type search | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7331@lists.php.net to get a copy of this message | ||
No SELECT COUNT (*) wouldnt work see I need to get the complete information
of all the listing to count how many time the searched keword matched within
EACH listing ID cause Lisitng has one to many relationship to keywords, so
one listing can have more than one instance of the keyword searched, I need
to list them arranged with listing with most hits first.
Any other ideas?
Oleg
-----Original Message-----
From: Steve Edberg [mailto:sbedberg@ucdavis.edu]
Sent: Wednesday, July 19, 2000 10:18 AM
To: Oleg Timofeyev; php-general@lists.php.net
Subject: Re: [PHP] PAGING and hosts.php.net type search
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! ---+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net