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 Link to comment https://forums.phpfreaks.com/topic/78869-solved-making-a-query-a-session/ 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. Link to comment https://forums.phpfreaks.com/topic/78869-solved-making-a-query-a-session/#findComment-399164 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()); ??? Link to comment https://forums.phpfreaks.com/topic/78869-solved-making-a-query-a-session/#findComment-399166 Share on other sites More sharing options...
Canman2005 Posted November 26, 2007 Author Share Posted November 26, 2007 do you mean as $_SESSION['sessioname'] ? Link to comment https://forums.phpfreaks.com/topic/78869-solved-making-a-query-a-session/#findComment-399167 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 Link to comment https://forums.phpfreaks.com/topic/78869-solved-making-a-query-a-session/#findComment-399168 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 ); Link to comment https://forums.phpfreaks.com/topic/78869-solved-making-a-query-a-session/#findComment-399173 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 Link to comment https://forums.phpfreaks.com/topic/78869-solved-making-a-query-a-session/#findComment-399183 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.... Link to comment https://forums.phpfreaks.com/topic/78869-solved-making-a-query-a-session/#findComment-399189 Share on other sites More sharing options...
Canman2005 Posted November 26, 2007 Author Share Posted November 26, 2007 thank you, works great Link to comment https://forums.phpfreaks.com/topic/78869-solved-making-a-query-a-session/#findComment-399216 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.