set_charset('utf8mb4'); $dbh->query('CREATE DATABASE IF NOT EXISTS EATERY_DB'); $dbh->select_db('EATERY_DB'); $dbh->query('CREATE TABLE IF NOT EXISTS `FOOD_DETAILS` (`FOOD_ID` INT PRIMARY KEY, `FOOD_ITEM` VARCHAR(255), `PRICE_PER_ITEM` DOUBLE, UNIQUE (`FOOD_ID`))'); $dbh->query('INSERT INTO `FOOD_DETAILS` VALUES (1, "Egg Biriyani (w/ 2 eggs)", 200), (2, "Chicken Biriyani", 300), (3, "Mutton Biriyani", 350), (4, "Veg Pulao", 200), (5, "Shahi Paneer", 220), (6, "Schezwan Paneer", 240), (7, "Steam Rice", 90) ON DUPLICATE KEY UPDATE `FOOD_ITEM` = VALUES(`FOOD_ITEM`)'); $dbh->query('CREATE TABLE IF NOT EXISTS `CUSTOMER_DETAILS` (`BILL_ID` INT PRIMARY KEY AUTO_INCREMENT, `CUSTOMER_NAME` VARCHAR(255), `TOTAL_AMOUNT_PAID` DOUBLE, `DATE_OF_PAYMENT` DATE)'); return $dbh; } function html_prologue($title) { ?> <?php echo $title; ?>

Operation failed

Reason:

Welcome to Delish Eatery

query('SELECT * FROM `FOOD_DETAILS`'); while ($row = $result->fetch_assoc()) { echo ''; echo '', ''; } ?>
ServingsFood itemPrice
', $row['FOOD_ITEM'], '₹', number_format(+$row['PRICE_PER_ITEM'], 2), '
query('SELECT * FROM `FOOD_DETAILS` WHERE `FOOD_ID` IN (' . implode(', ', $orders) . ')')->fetch_all(MYSQLI_ASSOC); $total_price = 0.0; foreach ($items as $i => $item) { $items[$i]['price'] = $servings[$item['FOOD_ID']] * $item['PRICE_PER_ITEM']; $total_price += $items[$i]['price']; } $tax = 0.15 * $total_price; $net_price = $total_price + $tax; $stmt = $dbh->prepare('INSERT INTO `CUSTOMER_DETAILS` (`CUSTOMER_NAME`, `TOTAL_AMOUNT_PAID`, `DATE_OF_PAYMENT`) VALUES (?, ?, ?)'); $stmt->bind_param('sds', $_POST['customer_name'], $net_price, @date('Y-m-d')); $stmt->execute(); $bill_id = $dbh->insert_id; html_prologue('Customer invoice'); ?>

Customer Invoice

Bill No.: D.E./

Name:

'; } ?>
Food itemServingsPrice
', implode('', [$item['FOOD_ITEM'], $servings[$item['FOOD_ID']], number_format($item['price'], 2)]), '
Total:
GST (15%):
Net price:
close(); } catch (mysqli_sql_exception $e) { display_failure($e->getMessage()); }