restaurant online web apps system

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’]; }
?>

Food Menu and Ordering Service
<img src="background.jpg" alt="Smiley face" height="200"
    width="900"></div>
<center>
  <p>&nbsp;</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); ?>





<?php // connect to the "food_menu_apps_system" database $conn = new mysqli('localhost', 'root', '123456', 'food_menu_apps_system'); // check connection if (mysqli_connect_errno()) { exit('Connect failed: '. mysqli_connect_error()); } // sql query for INSERT INTO users (two rows) $sql = "INSERT INTO `menu` (`tableno`, `product`, `quantity`) VALUES ('010', 'hoopa', '002'), ('009', 'shroom', '006')"; // Performs the $sql query on the server to insert the values if ($conn->query($sql) === TRUE) { echo 'users entry saved successfully'; } else { echo 'Error: '. $conn->error; } $conn->close(); // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "{$field->tableno}"; echo "{$field->product}"; echo "{$field->quality}"; echo "\n"; // printing table rows echo ""; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "$cell"; echo "\n"; } $con=mysqli_connect("localhost","root","123456","food_menu_apps_system"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } mysqli_query($con,"DELETE FROM menu WHERE 'tableno=001'"); mysqli_close($con); ?>

Order Meal 1

Order Meal 2

     <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]

Either you are not pulling in the data from the table properly or you’re getting errors but don’t realize it.

To insure you have error reporting put the following in you script (preferably at the top):
[php]ini_set(‘display_errors’,1);
error_reporting(E_ALL);[/php]

or edit your php.ini file and include this option:
[php]error_reporting = E_ALL[/php]

thank you… but now it says

Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\New folder (2)\htdocs\food_menu_apps_system\processorder.php on line 108
Total:B$0

how do i used mysqli or PDO

now i managed to fixed the error but i cant still get it to calculate the total price and quantity?? it still displayed Total:B$0

sorry this is my update:-

<?php //Start session session_start(); //create short variable name $DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"]; ini_set('display_errors',1); error_reporting(E_ALL); $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; if (isset($_COOKIE['count'])) { $count = $_COOKIE['count'] + 1; } else { $count = 1; } setcookie('count', $count, time()+3600); setcookie("Cart[$count]", $product, time()+3600); //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']; } ?> Food Menu and Ordering Service
<img src="background.jpg" alt="Smiley face" height="200"
    width="900"></div>
<center>
  <p>&nbsp;</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. '
'; echo "Total:B$", $total = ($price * $quantity); ?>


$(function(){ $("select[name='product'], select[name='quantity']").change(function(){ var quantity=$("select[name='quantity'] option:selected"); var product=$("select[name='product'] option:selected");

var price=parseFloat(quantity.val())*parseFloat(product.val());
$("#price").html('$'+price);
$("#quantity").val(product.html());

  function price() {    
      var price = document.getElementById('price').value;
      var quantity  = document.getElementById('quantity').value;
      var total = document.getElementById("total");
      total.value = price + quantity;
	  if( isNaN(quantity) ){
				alert('Enter only a number and try again.');
			}else{
				alert('Total: $'+(quantity*price));
			}
		}
  }
  </script>




<?php // connect to the "food_menu_apps_system" database $conn = new mysqli('localhost', 'root', '123456', 'food_menu_apps_system'); // check connection if (mysqli_connect_errno()) { exit('Connect failed: '. mysqli_connect_error()); } // Performs the $sql query on the server to insert the values if ($conn->query($sql) === TRUE) { echo 'users entry saved successfully'; } else { echo 'Error: '. $conn->error; } $conn->close(); // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "{$field->tableno}"; echo "{$field->product}"; echo "{$field->quality}"; echo "\n"; // printing table rows echo ""; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "$cell"; echo "\n"; } $con=mysqli_connect("localhost","root","123456","food_menu_apps_system"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } mysqli_query($con,"DELETE FROM menu WHERE 'tableno=001'"); mysqli_close($con); ?>

Order Meal 1

Order Meal 2

     <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>

why does it still displayed zero dollar as in “$0” at the total calculation?

Sponsor our Newsletter | Privacy Policy | Terms of Service