Canman2005 Posted November 26, 2007 Share Posted November 26, 2007 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 Quote Link to comment Share on other sites More sharing options...
revraz Posted November 26, 2007 Share Posted November 26, 2007 You can put an array in a Session variable. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 26, 2007 Share Posted November 26, 2007 just a random question but why are u supressing the errror with @ and then displaying it with an or(die(mysql_error()); ??? Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted November 26, 2007 Author Share Posted November 26, 2007 do you mean as $_SESSION['sessioname'] ? Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted November 26, 2007 Author Share Posted November 26, 2007 only because its the standard code i use for getting data from a table Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 26, 2007 Share Posted November 26, 2007 the question is very unclear... you set session as $_SESSION['x']= your value or store array in session $_SESSION['x']= array(values here ); Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted November 26, 2007 Author Share Posted November 26, 2007 so do i put the all the queries within $_SESSION['x']= array( IN HERE ); sorry, being a little thick tonight Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 26, 2007 Share Posted November 26, 2007 <?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.... Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted November 26, 2007 Author Share Posted November 26, 2007 thank you, works great Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.