Sorry about the rubbish explanation. I'll try again =) You'd think I'd know better by now =P
I have one table with a column named price. (to be clear the price is £2.50)
I am trying to calculate the VAT at 17.5% using price from the table called ride. Within the programme there is a chance to book two seats. what I an trying to do is to calculate the VAT for one seat or two seats; depending on what the user picked.
The user picks the seats from a drop down box on the second page of the booking system
Swing.php
Code: Select all
//DROP DOWN BOX ONE
$extract =mysql_query("SELECT * FROM ride WHERE rideID ='1'");
$numrows = mysql_num_rows($extract);
echo '<form method="post" name="f2" 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);
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'];
$name = $row ['rideName'];
$seatNumber = $row ['seatNumber'];
$time = $row ['time'];
$price = $row ['price'];
echo "<option name='seat2'> $seatNumber </option>";
$_SESSION['extract2']=$_POST['seat2'];
}
echo '</select><br>';
The price is called here and using the VAT function above shows the VAT of one seat and two seats, though just as variables. The end page for the insert into database query is three more pages away. Being as though there is already a SESSION for the seat number chosen I didn't think it possible to have price as a session too.
The price from the database has to have a VAT calculation applied and the total inserted into the database on the last page. It does not matter which page the VAT calculation is made on if the end results can be put into sessions; But I have little idea how to do this =(
The VAT function came from a code snippet that I modified to fit my script. here is the original if it helps.
Code: Select all
<?php
function vat($vat, $priceexvat)
{
return sprintf("%01.2f",($vat*$priceexvat/ 100));
}
?>
<?php
echo vat(17.5,300);
?>
At this present moment, I am unsure as to how I got my results but using the modified VAT function it returned the vat at 0.43 the price for one seat was $SSendPrice1 and for two seats was $SSendPrice2.
One seat is 2.94 (inc VAT)
Two seas is 5.88 (inc VAT)
If as you suggest the VAT function does not work then I am unsure how the code works properly and cannot explain how i got those results, at first I was just happy that I got them.. until i tired to insert them into the database that is =|
Sorry if this is long and If I have repeated myself alot.