On Mon, Nov 15, 2004 at 06:56:45PM -0600, Scott McWhite wrote: > 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? > > Error. > > Notice: Undefined index: searchterm in > C:\Inetpub\cars\search\my_php_file.php on line 2 > > Notice: Undefined index: searchterm1 in > C:\Inetpub\cars\search\my_php_file.php on line 3 > > Notice: Undefined index: searchterm2 in > C:\Inetpub\cars\search\my_php_file.php on line 4 > > My php file. > > <?php > $searchterm=$_POST['searchterm']; > $searchterm1=$_POST['searchterm1']; > $searchterm2=$_POST['searchterm2']; > > $searchterm = addslashes($searchterm); > $searchterm1 = addslashes($searchterm1); > $searchterm2 = addslashes($searchterm2); > > // Previous Link > > if($page > 1){ > $prev = ($page - 1); > echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; > } > > ...snip... > Thank you, > > > > Scott > Start with the first error message: > Notice: Undefined index: searchterm in > C:\Inetpub\cars\search\my_php_file.php on line 2 > Then look at line 2: > $searchterm=$_POST['searchterm']; This indicates that $_POST['searchterm'] is undefined. Why isn't it defined? In order to show up in the $_POST array, it would have to be POSTED, ie you could put it into a hidden field that could show up after the user pressed a Submit button. However, it doesn't appear that you are doing that. (Either that, or I snipped too much off your original post!) You have Previous and Next hyperlinks, each of which passes the page number in the query string. Perhaps you could also pass the searchterm(s) in the query string. Or, you could store them in the $_SESSION array. If you do this, be sure to start the session. -- Jim Kaufman Linux Evangelist public key 0x6D802619 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php