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@xxxxxxxxxx
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php