Forum Moderators: coopster

Message Too Old, No Replies

php session in search criteria

keeping search criteria in search bar on refresh

         

Emily_Gems

12:49 am on Jul 11, 2008 (gmt 0)

10+ Year Member



Hello, I am somewhat new to php. I am slowly turning from a Dreamweaver user to trying to do more in code on my own. Anyway I have a site up that has a search bar. Currently I am displaying all of the results but would like to only display 10 at a time. The problem is that when I display ten and then go to the next page the search criteria is gone and I get a blank page?

Looking at google for example, I see that I need to keep the text in the search box when the page refreshes and when you navigate to the second page.

I think I need to use a session for this, however I have not been successful at doing this. The search is on every page. Here is the site if you need an idea of what I am trying to accomplish. Any help would be much appreciated.

[edited by: eelixduppy at 5:10 am (utc) on July 11, 2008]
[edit reason] removed URL [/edit]

cameraman

7:02 am on Jul 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try putting this at the top of any script that is going to read or write to $_SESSION and see if that helps:
session_start(); [us2.php.net]

Writing and reading is incredibly easy:
$_SESSION['criteria'] = $criteria;

$criteria = $_SESSION['criteria'];

(And no, they don't have to be named the same, I just find it easier on the brain).

As a side note, google, yahoo, and msn put the search criteria in the url's query string.