session-handling
Posted: Sat Mar 10, 2007 12:08 pm
I have this php-code that writes out the querytime and no. of hits from a mySQL-search on the very same page.
Problem is, it's one step behind. That is, when I enter the searchpage and hit search, It doesnt show up, but if i hit search button again it'll show up, showing me the values of the previous search.
I can't find the problem here...
On the 'main' page, Ill fetch the info, if the sessionvar is set, else there havent been a query yet..
One of the session var is set in querytires();
(render_table() just returns a table with the searchresults, it doesnt modify the session variabel)
Any point in the right direction would be helpful.. Im very new to php..:-/
Problem is, it's one step behind. That is, when I enter the searchpage and hit search, It doesnt show up, but if i hit search button again it'll show up, showing me the values of the previous search.
I can't find the problem here...
On the 'main' page, Ill fetch the info, if the sessionvar is set, else there havent been a query yet..
Code: Select all
if(isset($_SESSION['querytime']))
{
echo "<p>Sökningen tog <strong>". $_SESSION['querytime'] ."</strong> sekunder</p>";
echo "Antal träffar : " . $_SESSION['hits'];
}
?>Code: Select all
function querytires($params)
{
connect();
$query="
SELECT fabrikat,monster,li,ss,dimension,typ,bto_pris,nto_pris,
fsg_pris,lagersaldo,img_url,leverantor,info_txt FROM dack";
$search_p = array();
foreach($params AS $name=>$value)
{
if($value!=""){
array_push($search_p, "$name = '$value'");
}
}
if(count($search_p)>0)
$query .= "WHERE ".implode(" AND ", $search_p);
$start_t = getTime();
$results = mysql_query($query) or die(mysql_error());
$stop_t = getTime();
$total = $stop_t - $start_t;
$_SESSION['querytime'] = round( $total, 4);
$restable = render_table($results);
return $restable;
}Any point in the right direction would be helpful.. Im very new to php..:-/