jsk1gcc Posted January 14, 2011 Share Posted January 14, 2011 Hi, I could really do with some help putting the prices from two drop down boxes into sessions To start with the user can choose two seats one from each drop down box //DROP DOWN BOX ONE $extract =mysql_query("SELECT * FROM ride WHERE rideID ='1'"); $numrows = mysql_num_rows($extract); //start of form echo '<form method="post" name="f1" action="card.php">'; echo 'Please choose a seat: '; echo"<select name='seat' >"; while( $row = mysql_fetch_assoc($extract)) { $rideID = $row ['rideID']; $name = $row ['name']; $seatNumber = $row ['seatNumber']; $time = $row ['time']; $price = $row ['price']; echo "<option name='seat'> $seatNumber </option>"; $_SESSION['extract']=$_POST['seat']; } echo '</select><br>'; //DROP DOWN BOX TWO $extract2 =mysql_query("SELECT * FROM ride WHERE rideID ='1'"); $numrows = mysql_num_rows($extract2); //start of form echo '<form method="post" name="f2" action="card.php">'; echo 'Please choose a seat: '; echo"<select name='seat2' >"; while( $row = mysql_fetch_assoc($extract2)) { $rideID = $row ['rideID']; $rideName = $row ['rideName']; $seatNumber = $row ['seatNumber']; $time = $row ['time']; $price = $row ['price']; echo "<option name='seat2'> $seatNumber </option>"; $_SESSION['extract2']=$_POST['seat2']; } echo '</select><br>'; at the moment I have this : $query =mysql_query("SELECT price FROM ride WHERE rideID ='1' LIMIT 1"); while ($row=mysql_fetch_array($query)) { echo $row['price']; echo "<br>"; $seatPrice1=($row['price']); $seatPrice2=($row['price']*2); $vat1=17.5; function vat($vat, $row['price']) { return sprintf("%01.2f", ($vat*$row['price]/ 100)); } $vatprice = vat(17.5, 2.50); $total1=($vatprice); $total2=($vatprice*2); $endPrice1= ($total1+$seatPrice1); $endPrice2= ($total2+$seatPrice2); What I need is $endPrice1 and $endPrice2 in $_SESSIONS so i an INSERT them in to the database 3 pages away from this query/VAT fucntion. Can anyone help? Quote Link to comment Share on other sites More sharing options...
revraz Posted January 14, 2011 Share Posted January 14, 2011 A session is just like any other variable, you store it the same way. What part exactly do you need help with? Quote Link to comment Share on other sites More sharing options...
jsk1gcc Posted January 14, 2011 Author Share Posted January 14, 2011 Where should I declare them, after $endPrice1= ($total1+$seatPrice1); $endPrice2= ($total2+$seatPrice2); ?? A look at the syntax and structure of the query would bea great help too =) Quote Link to comment Share on other sites More sharing options...
dragon_sa Posted January 14, 2011 Share Posted January 14, 2011 $_SESSION['total1']=$endprice1; $_SESSION['total2']=$endprice2; yes declare them after you declare $endprice1 and $endprice2 to access them again simple call the sessions $price1=$_SESSION['total1']; $price2=$_SESSION['total2']; Quote Link to comment Share on other sites More sharing options...
jsk1gcc Posted January 14, 2011 Author Share Posted January 14, 2011 Notice: Undefined variable: endprice1 on line 120 Notice: Undefined variable: endprice2 in p on line 121 It does not like them, I'm unsure what to to? Quote Link to comment Share on other sites More sharing options...
jsk1gcc Posted January 14, 2011 Author Share Posted January 14, 2011 Ignore last post, silly me, spelt them wrong Thanks dragon_sa, i'll try inserting them and let you know how it goes =) 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.