Pagination need help
| From: | Scott McWhite | Date: | Thu, 04 Nov 2004 04:22:43 +0000 |
| Subject: | Pagination need help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-201119@lists.php.net to get a copy of this message | ||
Hi,
Im using an HTML search form that passes the searchterm to a php file.
In my case the searchterm can have 1000s of records in my database, so I
implemented a limit which displays 20 records per page. The pagination
function works fine with one exception. Example of my problem: searchterm
typed in the html search form equals ford, in the database there are 2000
fords, the first page displays 20 fords and then the next page forgets that
we are searching fords and displays the equivalent to a wildcard %
search and displays accordingly.
Does anyone have sample code for using an HTML search form with pagination?
Generally what Im trying to do is type a searchterm on the html search
page, have the php file run the query and if it is an item that has many
results to display it 20 records per page without it displaying every record
in the database.
Here is some of the code:
$searchterm=$_POST['searchterm'];
$searchterm1=$_POST['searchterm1'];
$searchterm2=$_POST['searchterm2'];
$sql = "select * from cars where ".'car'." like
'%".$searchterm."%' AND
".'seller'." like '%".$searchterm1."%' AND
".'description'." like
'%".$searchterm2."%' ORDER BY 'car', 'price' LIMIT $from,
$max_results";
Thank you.