I'm making a simple search engine for a site. It works great now, but will display all of the results on one page. I am attempting to make it gracefully return 10 results at a time. I need to read both get and post data (at least the way I have it set up now). To do so, I'm using this:
Code: Select all
$input = strtolower($_REQUESTї'searchtext']);
$offset = $_REQUESTї'offset'];
if (!$offset) $offset = 0;
That works fine. Next I have it read the data from the database (dba, really simple), and select just the 10 that I want for display using this code:
Code: Select all
$results2 = array_slice($results, $offset, 10);
At the bottom I have a the prev/next kind of set up where like this:
Code: Select all
if ($offset+10 <= $count) echo "<a href='$PHP_SELF?searchtext=$input&offset=".($offset+10)."'>Next</a> ";
where $count is the total number of results. I have similar stuff for the prev link. It works fine, but the url in the browser window ends up getting kind of garbled. I don't mind having the offset number passed visibly, but is there a way I can just resend the current post data (the searchtext)without having to include it in the url? Thanks for the help.