Use 2 queries. 1) SELECT * FROM cars WHERE ... ORDER BY... "; 1) SELECT * FROM cars WHERE ... ORDER BY... LIMIT $record_x_page OFFSET $page";
With the firsth query print pages numbers at the bottom of the html page. With the second one print the records list. Every time you click on the page number printed at the bottom you have to pass the searchterms (by get with urlencode()) to the 2 queries and the $page parameter. Sebastiano Alle 05:22, giovedì 4 novembre 2004, Scott McWhite ha scritto: > Hi, > > > > I’m 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 I’m 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php