RE: [PHP-DB] next prev links for search result
| From: | joakim dot andersson at cybercom dot se | Date: | Tue, 27 Aug 2002 07:38:45 +0000 |
| Subject: | RE: [PHP-DB] next prev links for search result | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-21380@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Smita Manohar [mailto:smitamanohar@hotmail.com]
> Sent: Monday, August 26, 2002 8:26 PM
> To: php-db@lists.php.net
> Subject: [PHP-DB] next prev links for search result
>
>
> hiii..
>
> i want page no. and next prev links while displaying search
> result. the
> script which im using presently, needs to run the search
> query 2 times for
> each search operation.
>
> first time it finds all the records matching the query string,
>
Change this query:
> ie, select * from table where field like '%$search_string %'
>
To
SELECT COUNT(*) AS num_hits FROM table WHERE field LIKE '%$search_string%'
and let your MySQL-server do the counting. No need to transfer all data to
PHP just to count the rows.
You still have to run two queries, but I don't think you need to worry too
much about performance issues, unless you have a really, really huge table.
Regards
Joakim Andersson