Re: Working with sessions
| From: | Jason Pruim | Date: | Fri, 21 Sep 2007 18:30:18 +0000 |
| Subject: | Re: Working with sessions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-262347@lists.php.net to get a copy of this message | ||
On Sep 21, 2007, at 2:26 PM, Jay Blanchard wrote:
[snip] I have a question about sessions, I am attempting to store a search term in a session variable to that when it finds the set of records from the database it can export it to excel. The problem I have is that the session variable is 1 search behind... [/snip] When you do the search store the search term immediately to the session variable; <?php //pseudo-code start_session(); $_SESSION['searchTerm'] = $_GET['searchTerm']; ?> <html> <a href="link to excel sheet"> </html> Now in the code that generates the excel; <?php session_start(); $getStuffForExcel = "SELECT foo, bar FROM data where foo = '".$_SESSION['searchTerm']."' "; ?>Wouldn't that be what this code does: <?PHP if ($_SESSION['search'] != NULL){ echo "The search string is: <strong>$search</strong>.<BR>"; $qrow[]= mysql_query($qstring) or die(mysql_error()); $qresult = $qrow[0]; $num_rows = mysql_num_rows($qresult); //display search form echo " <form action='search.php' method='GET'> <label>Search: <input type='text' name='search' id='search' /> </label> <input type='submit' value='Go!' /> </form>"; $_SESSION['search'] = $_GET['search']; ?> It also displays the search results on the same page and that display works just fine. Just the session variable that's messed up. Thanks for looking though :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com japruim@raoset.com