We can make a bill payment system in PHP using Jquery and Bootstrap. We can make any type of restaurant’s bill payment system using PHP.How to make a Bill Receipt Software in PHP.
Learn about PHP from its Official Website :https://www.php.net/
How to make a dependent Dropdown in Laravel : Dropdown in Laravel
We can create a browser-based billing software in PHP. So if you’re looking for an invoice or billing system using PHP and MySQL, then you’re here at the right place. In this tutorial, you will learn how to make software

The database name is bill_receipt ( Below code for table )
-- -- Database: `bill_reciept` -- -- -------------------------------------------------------- -- -- Table structure for table `orders` -- CREATE TABLE `orders` ( `id` int(11) NOT NULL, `proudct_id` varchar(55) NOT NULL, `product_name` varchar(55) NOT NULL, `product_price` int(11) NOT NULL, `product_qty` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `orders` -- INSERT INTO `orders` (`id`, `proudct_id`, `product_name`, `product_price`, `product_qty`) VALUES (1, 'ml01', 'Malai Kadhaai', 250, 2), (2, 'pn01', 'Paneer Mutter', 150, 3), (3, 'pn02', 'Paneer Aloo', 120, 4), (4, 'rm1', 'Tandoori Roti', 25, 2), (5, 'rm1', 'Butter Roti', 35, 2), (6, 'jr01', 'Jeera Rice', 110, 2), (7, 'kf1', 'Veg Kofta', 230, 2), (8, 'mt01', 'Mutton Curry', 425, 1), (9, 'ck01', 'Chicken Cury', 210, 1), (10, 'ck02', 'Chicken Masala', 110, 1), (11, 'ck03', 'Chicken Rice', 150, 1), (12, 'rt01', 'Onion Rayata', 45, 1), (13, 'rt02', 'Onine Curd Rayata', 90, 1); // Code ends
First, create connection file db.php
<?php include("db.php"); $sql = "SELECT * FROM orders WHERE id='".$_POST['id']."'"; $query = mysqli_query($conn,$sql); while($row = mysqli_fetch_assoc($query)) { $data = $row; } echo json_encode($data); ?>
Now create a fetch.php page for data fetching from the database.
<?php
include("db.php");
$sql = "SELECT * FROM orders WHERE id='".$_POST['id']."'";
$query = mysqli_query($conn,$sql);
while($row = mysqli_fetch_assoc($query))
{
$data = $row;
}
echo json_encode($data);
?>
Then, create index.php
<?php
include("db.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>Document</title>
<style>
.result{
color:red;
}
td
{
text-align:center;
}
</style>
</head>
<body>
<section class="mt-3">
<div class="container-fluid">
<h4 class="text-center" style="color:green"> Delhi Restaurent & Motel </h4>
<h6 class="text-center"> Shine Metro Mkadi Naka (New - Delhi)</h6>
<div class="row">
<div class="col-md-5 mt-4 ">
<table class="table" style="background-color:#f5f5f5;">
<thead>
<tr>
<th>No.</th>
<th>Meal Items</th>
<th style="width: 31%">Qty</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td scope="row">1</td>
<td style="width:60%">
<select name="vegitable" id="vegitable" class="form-control">
<?php
$sql = "SELECT * FROM orders";
$query = mysqli_query($conn,$sql);
while($row = mysqli_fetch_assoc($query)){
?>
<option id="<?php echo $row['id']; ?>" value="<?php echo $row['product_name']; ?>" class="vegitable custom-select">
<?php echo $row['product_name']; ?>
</option>
<?php }?>
</select>
</td>
<td style="width:1%">
<input type="number" id="qty" min="0" value="0" class="form-control">
</td>
<td>
<p id="price"></p>
</td>
<td><button id="add" class="btn btn-primary">Add</button></td>
</tr>
</tbody>
</table>
<div role="alert" id="errorMsg" class="mt-5" >
<!-- Error msg -->
</div>
</div>
<div class="col-md-7 mt-4" style="background-color:#f5f5f5;">
<div class="p-4">
<div class="text-center">
<h4>Receipt</h4>
</div>
<span class="mt-4"> Time : </span><span class="mt-4" id="time"></span>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6 ">
<span id="day"></span> : <span id="year"></span>
</div>
<div class="col-xs-6 col-sm-6 col-md-6 text-right">
<p>Order No:</p>
</div>
</div>
<div class="row">
</span>
<table id="receipt_bill" class="table">
<thead>
<tr>
<th> No.</th>
<th>Product Name</th>
<th>Quantity</th>
<th class="text-center">Price</th>
<th class="text-center">Total</th>
</tr>
</thead>
<tbody id="new" >
</tbody>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td class="text-right text-dark" >
<h5><strong>Sub Total: ₹ </strong></h5>
<p><strong>Tax (5%) : ₹ </strong></p>
</td>
<td class="text-center text-dark" >
<h5> <strong><span id="subTotal"></strong></h5>
<h5> <strong><span id="taxAmount"></strong></h5>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td class="text-right text-dark">
<h5><strong>Gross Total: ₹ </strong></h5>
</td>
<td class="text-center text-danger">
<h5 id="totalPayment"><strong> </strong></h5>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</section>
</body>
</html>
<script>
$(document).ready(function(){
$('#vegitable').change(function() {
var id = $(this).find(':selected')[0].id;
$.ajax({
method:'POST',
url:'fetch_product.php',
data:{id:id},
dataType:'json',
success:function(data)
{
$('#price').text(data.product_price);
//$('#qty').text(data.product_qty);
}
});
});
//add to cart
var count = 1;
$('#add').on('click',function(){
var name = $('#vegitable').val();
var qty = $('#qty').val();
var price = $('#price').text();
if(qty == 0)
{
var erroMsg = '<span class="alert alert-danger ml-5">Minimum Qty should be 1 or More than 1</span>';
$('#errorMsg').html(erroMsg).fadeOut(9000);
}
else
{
billFunction(); // Below Function passing here
}
function billFunction()
{
var total = 0;
$("#receipt_bill").each(function () {
var total = price*qty;
var subTotal = 0;
subTotal += parseInt(total);
var table = '<tr><td>'+ count +'</td><td>'+ name + '</td><td>' + qty + '</td><td>' + price + '</td><td><strong><input type="hidden" id="total" value="'+total+'">' +total+ '</strong></td></tr>';
$('#new').append(table)
// Code for Sub Total of Vegitables
var total = 0;
$('tbody tr td:last-child').each(function() {
var value = parseInt($('#total', this).val());
if (!isNaN(value)) {
total += value;
}
});
$('#subTotal').text(total);
// Code for calculate tax of Subtoal 5% Tax Applied
var Tax = (total * 5) / 100;
$('#taxAmount').text(Tax.toFixed(2));
// Code for Total Payment Amount
var Subtotal = $('#subTotal').text();
var taxAmount = $('#taxAmount').text();
var totalPayment = parseFloat(Subtotal) + parseFloat(taxAmount);
$('#totalPayment').text(totalPayment.toFixed(2)); // Showing using ID
});
count++;
}
});
// Code for year
var currentdate = new Date();
var datetime = currentdate.getDate() + "/"
+ (currentdate.getMonth()+1) + "/"
+ currentdate.getFullYear();
$('#year').text(datetime);
// Code for extract Weekday
function myFunction()
{
var d = new Date();
var weekday = new Array(7);
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var day = weekday[d.getDay()];
return day;
}
var day = myFunction();
$('#day').text(day);
});
</script>
<!-- // Code for TIME -->
<script>
window.onload = displayClock();
function displayClock(){
var time = new Date().toLocaleTimeString();
document.getElementById("time").innerHTML = time;
setTimeout(displayClock, 1000);
}
</script>
Subscribe to My Programming YouTube Channel before downloading the Source Code
.
.
Download the Source Code:- Source Code (Click on Source code )
Now run this code in browser .
Notice: Undefined index: id in C:\xampp\htdocs\bill\db.php on line 4
Notice: Undefined variable: data in C:\xampp\htdocs\bill\db.php on line 10
null
im getting ts error and price is not printing
can you plz help me with ts
Please don’t change the file name..in Jquery code …
$.ajax({
method:’POST’,
url:’fetch_product.php’,
data:{id:id},
dataType:’json’,
fetch_product.php this file name is fetching Price …so make sure this file name is same as the link
Are you sure your db.php is alright ?
or you have given the fetch_product.php same codes in db.php ?
Maybe I have done wrong but you can set Config code in db.php
how do i fix the Warning: mysqli_connect(): (HY000/1049): Unknown database ‘bill_receipt’ in C:\xampp\htdocs\bill_payment\db.php on line 3
Failed to connect to MySQL: Unknown database ‘bill_receipt’
Your database name must be wrong make sure database name must be same as your code
Plz Share Codeigniter Code, actually im facing error, add more product product vlaue is undifiend and , how can solve it
Make sure value is define or not
You might have missed to define it