You're not saving the query per se; you're saving the WHERE clause. When the user clicks to pull up an individual record, say id=3, you need to re-run that search query again, and go through the results to find both the previous and next record, and extract their ID numbers to populate the link. You can do that by using your WHERE clause (to get the same list of records), and then add an extra clause - WHERE id > 3 ORDER BY id LIMIT 1. You'll need to do it twice (WHERE id < 3 ORDER BY id LIMIT 1) to get the previous record, too.
↧