Jump to content

[SOLVED] Making a query a SESSION


Canman2005

Recommended Posts

hi all

 

i have a query which looks like

 

<?php
		$sql = "SELECT * FROM bes_optionals ORDER BY title ASC";
		$show = @mysql_query($sql,$connection) or die(mysql_error());
		while ($row = mysql_fetch_array($show))
		{
		if($row['type'] == 1)
		{
		if($_GET[$row['id']] == 1)
		{
		print ''.$row['title'].' at a cost of £'.number_format($row['cost'], 2, '.', '').'';
		print "<br><br>";			
		}
		}
		elseif($row['type'] == 2)
		{
		if($_GET[$row['id']] == 1)
		{
		print '1 '.$row['title'].' at a cost of £'.number_format($row['cost'], 2, '.', '').'';
		print "<br><br>";			
		}
		elseif($_GET[$row['id']] == 2)
		{
		print '2 '.$row['title'].' at a cost of £'.number_format(($row['cost']*2), 2, '.', '').'';
		print "<br><br>";			
		}
		elseif($_GET[$row['id']] == 3)
		{
		print '3 '.$row['title'].' at a cost of £'.number_format(($row['cost']*3), 2, '.', '').'';
		print "<br><br>";			
		}
		elseif($_GET[$row['id']] == 4)
		{
		print '4 '.$row['title'].' at a cost of £'.number_format(($row['cost']*4), 2, '.', '').'';
		print "<br><br>";			
		}
		}
		}
            ?>

 

this outputs something like

 

RG564 at a cost of £40

C45HY at a cost of £10

 

is it possible to make everything that is outputted by these two queries as a session and store what has been outputed

 

any help would be great

 

thanks

 

ed

Link to comment
https://forums.phpfreaks.com/topic/78869-solved-making-a-query-a-session/
Share on other sites

<?php
$sql = "SELECT * FROM bes_optionals ORDER BY title ASC";
$show = @mysql_query($sql,$connection) or die(mysql_error());
while ($row = mysql_fetch_array($show)){
if($row['type'] == 1){
	if($_GET[$row['id']] == 1){
		$text.=''.$row['title'].' at a cost of £'.number_format($row['cost'], 2, '.', '').'';
		$text.= "<br><br>";			
	}
}
elseif($row['type'] == 2){
	if($_GET[$row['id']] == 1){
		$text.= '1 '.$row['title'].' at a cost of £'.number_format($row['cost'], 2, '.', '').'';
		$text.= "<br><br>";			
	}
	elseif($_GET[$row['id']] == 2){
		$text.= '2 '.$row['title'].' at a cost of £'.number_format(($row['cost']*2), 2, '.', '').'';
		$text.= "<br><br>";			
	}
	elseif($_GET[$row['id']] == 3){
		$text.= '3 '.$row['title'].' at a cost of £'.number_format(($row['cost']*3), 2, '.', '').'';
		$text.= "<br><br>";			
	}
	elseif($_GET[$row['id']] == 4){
		$text.= '4 '.$row['title'].' at a cost of £'.number_format(($row['cost']*4), 2, '.', '').'';
		$text.= "<br><br>";			
	}
}
}

//set session
$_SESSION['yoursession']= $text;
echo $text;
//this might not exactly you want but this might give you an idea 
?>

 

i edited few lines try....

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.