Pagination need help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

 


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux