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
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....

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.