Jump to content

store query results in session variable


xiao

Recommended Posts

is it possible? Because I need to find an easy way to cache my query results.

I have this:

function sessie($qry,$product){
while($rij = mysql_fetch_assoc($qry)){
	$_SESSION['qryProductid'][$product] = $rij['products_id'];
	$_SESSION['qryProductnaam'][$product] = $rij['products_name'];
	$_SESSION['qryProductprijs'][$product] = $rij['products_price'];
}
}

 

If that works, how do I transform this? (old query result output)

while($rij = mysql_fetch_array($qry))
	{
		$prijs = number_format($rij['products_price'],2, ',', '');
	    echo "<option value=\"" . $rij['products_id'] . " - " . $prijs . "\"";
	    if($_SESSION['productid'][$productsoort] == $rij['products_id']) echo " SELECTED ";
		echo ">" . $rij['products_name'] . " - €" . $prijs . "</option>\n";
	}

Link to comment
https://forums.phpfreaks.com/topic/102428-store-query-results-in-session-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.