i am new to this php programming can anyone help me with this. my problem is the computer is not running the calculation at line 105-111. there are no more errors but it doesnt displayed the total price for quantity and price of product. how to i fixed this?
this is my full code:-
[php]<?php
//Start session
session_start();
//create short variable name
$DOCUMENT_ROOT = $_SERVER[“DOCUMENT_ROOT”];
$product=’’;
$price=’’;
$quantity=’’;
$tableno=’’;
$total=‘0.00’;
$count=3;
$totalqty = 0;
$totalamount = 0.00;
$menu=’’;
$result=’’;
$totalqty = 0;
$totalamount = 0.00;
// initialize running sums
$total = 0;
//define the variable price of each product
define(“basik”, 3.60);
define(“hoopa”, 3.80);
define(“cheezy”, 4.50);
define(“shroom”, 2.50);
define(“akon”, 4.50);
define(“rush”, 4.00);
define(“bing”, 4.50);
define(“kombo”, 6.00);
$fields_num=’’;
$tableno = $_POST[‘tableno’];
$product = $_POST[‘product’];
$quantity = $_POST[‘quantity’];
if(isset($_POST[‘total’])){ $total = $_POST[‘total’]; }
if(isset($_POST[‘quantity’])){ $quantity = $_POST[‘quantity’]; }
if(isset($_POST[‘product’])){ $product = $_POST[‘product’]; }
?>
width="900"></div>
<center>
<p> </p>
<p style="background-color: lightblue;"> <a href="http://localhost/food_menu_apps_system/index.php">Home</a>
<a href="http://localhost/food_menu_apps_system/introduction.php">Introduction</a>
<a href="http://localhost/food_menu_apps_system/sitemap.php">Site Map</a>
<a href="http://localhost/food_menu_apps_system/job.php">Job
Advertisement</a> <a href="http://localhost/food_menu_apps_system/history.php">History</a>
<a href="http://localhost/food_menu_apps_system/location.php">Location</a>
<a href="http://localhost/food_menu_apps_system/news.php">News</a> <a href="http://localhost/food_menu_apps_system/event.php">Event</a>
<a href="http://localhost/food_menu_apps_system/feedback.html">Customer
Feedback</a> </p>
<h2 style="background-color: lightblue;"> Order Result</h2>
<h2 style="background-color: lightblue;">
<p style="background-color: lightblue;">
<?php
$link = mysqli_connect("localhost", "root", "123456", "food_menu_apps_system");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$tableno = mysqli_real_escape_string($link, $_POST['tableno']);
$product = mysqli_real_escape_string($link, $_POST['product']);
$quantity = mysqli_real_escape_string($link, $_POST['quantity']);
// attempt insert query execution
$sql = "INSERT INTO menu(tableno, product, quantity) VALUES ('$tableno', '$product', '$quantity')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
$quantity = $_POST['quantity'];
if(isset($_POST['total'])){ $total = $_POST['total']; }
if(isset($_POST['quantity'])){ $quantity = $_POST['quantity']; }
if(isset($_POST['product'])){ $product = $_POST['product']; }
echo 'Order processed Verification
'; echo "Order processed at ".date('H:i, j F Y')."
"; //please show the $tableno, $product and $quantity on the web echo 'Your order is as follows:
'; echo 'You are at table:'; echo $tableno. ''; echo 'Your product are:'; echo $product. '
'; echo 'The amount of items you selected are:'; echo $quantity. '
'; $total = 0; // For Calculating Grand Price $total = mysql_query($sql); if($total) { list($quantity, $price) = mysql_fetch_row($total); $total = number_format($price * $quantity, 2); } echo "Total:B$", $total = ($price * $quantity); ?>
<p style="background-color: pink;"><a href="http://localhost/food_menu_apps_system/orderform2.html">Order Meal 3</a>
<p style="background-color: pink;"> <a href="http://localhost/food_menu_apps_system/orderform3.html">Order Meal 4</a>
<p style="background-color: lightblue;"><span style="font-family: MS Shell Dlg;">Copyright
2014-2015</span> </p>
</center>
[/php]
the main not reading and displaying the total price is here:-
[php]$total = 0; // For Calculating Grand Price
$total = mysql_query($sql);
if($total) {
list($quantity, $price) = mysql_fetch_row($total);
$total = number_format($price * $quantity, 2);
}
echo “Total:B$”, $total = ($price * $quantity);
[/php]