I want the price to Match the correct Valeu selected in the dropdown menu.
Thank You
Code: Select all
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="modify"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql= "SELECT * FROM `modify` ORDER BY `ID` ASC";
$result = mysql_query($sql);
$rows = mysql_num_rows($result);
?>
<form action="count.php" method="post">
<strong><a href="javascript:void(0);" onClick="document.getElementById('tab1').style.display='block';document.getElementById('tab2').style.display='none';document.getElementById('tab3').style.display='none';document.getElementById('tab4').style.display='none';document.getElementById('tab5').style.display='none';document.getElementById('tab6').style.display='none';" onDblClick="document.getElementById('tab1').style.display='none';document.getElementById('tab2').style.display='none';document.getElementById('tab3').style.display='none';document.getElementById('tab4').style.display='none';document.getElementById('tab5').style.display='none';document.getElementById('tab6').style.display='none';">Pages</a></strong><br />
<div id="tab1" style="display:none; font-size:11;">
Single Sided B&W
<input type="radio" name="bw/c" value="1" /><br />
Double Sided B&W
<input type="radio" name="bw/c" value="2" /><br />
Single Sided Colour
<input type="radio" name="bw/c" value="3" /><br />
Double Sided Colour
<input type="radio" name="bw/c" value="4" /><br />
<?php
echo '<select name="Ptype">';
while($data = mysql_fetch_assoc($result)) {
echo '<option name="bw/c/pt" value="'.$data['Valeu'].'">'.$data['Name'].'</option>'."\n";
}
echo '</select>';
?>
</div>
<input type="submit" value="Total" />
</form>
<?php
require_once ('includes.php');
// set quantity
$quantity = 4;
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="modify"; // Table name
// Connect to server and select databse.
echo $data['Valeu'];
$answer = $_POST['bw/c/pt'];
if ($answer == $data['Valeu']) {
echo $data['Valeu'];
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql= "SELECT * FROM `modify` WHERE Price = '$data[Valeu]'";
$result = mysql_query($sql);
$rows = mysql_num_rows($result);
while($data = mysql_fetch_assoc($result)) {
echo $data['Valeu'];
$origPrice = $data['Price'] ; }
}
else {
// set original and current unit price
$origPrice = 20;
}
// set original and current unit price
$currPrice = $origPrice * $quantity;
// calculate difference in price
$tax = 16;
// calculate percentage change in price
$PriceTaxed = round((($currPrice * $tax)/100) + $currPrice,0);
?>
<strong>
<div id="tab6" style="display:block;">
<table border="1" cellpadding="5" cellspacing="0" >
<tr><td>Quantity</td><td>Cost price Per Page</td><td>Current price Without Vat</td><td>Vat</td><td>Total Cost With Vat</td>
</tr>
<tr align="center"><td>
<?php echo $quantity; ?></td><td>$
<?php echo $origPrice; ?></td><td>$
<?php echo $currPrice; ?></td><td>
<?php echo $tax; ?>%</td><td>$
<?php echo $PriceTaxed; ?></td>
</tr>
</table><br /><br />
</div>