In our previous tutorial, we have explained how to develop Inventory System with Ajax, PHP & MySQL. In this tutorial, we will explain how to develop your own invoice system with PHP and MySQL.
Invoice or Billing Management Systems are very popular as now most of transactions are done online. Now every sellers and buyers needs invoice system to handle billing online. So if you’re looking for invoice or billing system using PHP and MySQL, then you’re here at right place. In this tutorial you will learn how to develop invoice and billing system using PHP and MySQL.

We will cover this tutorial in easy steps with live demo to develop complete invoice system to create and edit invoices with invoice print to convert into PDF format. We will also allow to download complete source code of live demo.

As we will cover this tutorial with live example to build invoice system with PHP & MySQL, so the major files for this example is following.
Step1: Create MySQL Database Tables
First we will create table invoice_user to store user login details to allow logged in user to manage invoices.
CREATE TABLE `invoice_user` ( `id` int(11) NOT NULL, `email` varchar(100) NOT NULL, `password` varchar(100) NOT NULL, `first_name` varchar(100) NOT NULL, `last_name` varchar(100) NOT NULL, `mobile` bigint(20) NOT NULL, `address` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ALTER TABLE `invoice_user` ADD PRIMARY KEY (`id`); ALTER TABLE `invoice_user` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=123457;
Here is the sample user dump data:
INSERT INTO `invoice_user` (`id`, `email`, `password`, `first_name`, `last_name`, `mobile`, `address`) VALUES (123456, 'admin@phpzag.com', '12345', 'Admin', '', 12345678912, 'New Delhi 110096 India.');
We will create table invoice_order to store invoice details.
CREATE TABLE `invoice_order` ( `order_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `order_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `order_receiver_name` varchar(250) NOT NULL, `order_receiver_address` text NOT NULL, `order_total_before_tax` decimal(10,2) NOT NULL, `order_total_tax` decimal(10,2) NOT NULL, `order_tax_per` varchar(250) NOT NULL, `order_total_after_tax` double(10,2) NOT NULL, `order_amount_paid` decimal(10,2) NOT NULL, `order_total_amount_due` decimal(10,2) NOT NULL, `note` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ALTER TABLE `invoice_order` ADD PRIMARY KEY (`order_id`); ALTER TABLE `invoice_order` MODIFY `order_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=682;
Here is sample dump data for invoice order:
INSERT INTO `invoice_order` (`order_id`, `user_id`, `order_date`, `order_receiver_name`, `order_receiver_address`, `order_total_before_tax`, `order_total_tax`, `order_tax_per`, `order_total_after_tax`, `order_amount_paid`, `order_total_amount_due`, `note`) VALUES (2, 123456, '2021-01-31 19:33:42', 'abcd', 'Admin\r\nA - 4000, Ashok Nagar, New Delhi, 110096 India.\r\n12345678912\r\nadmin@phpzag.com', 342400.00, 684800.00, '200', 1027200.00, 45454.00, 981746.00, 'this note txt');
We will also create table invoice_order_item to store invoice items details.
CREATE TABLE `invoice_order_item` ( `order_item_id` int(11) NOT NULL, `order_id` int(11) NOT NULL, `item_code` varchar(250) NOT NULL, `item_name` varchar(250) NOT NULL, `order_item_quantity` decimal(10,2) NOT NULL, `order_item_price` decimal(10,2) NOT NULL, `order_item_final_amount` decimal(10,2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ALTER TABLE `invoice_order_item` ADD PRIMARY KEY (`order_item_id`); ALTER TABLE `invoice_order_item` MODIFY `order_item_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4364;
Here is sample dump data for invoice order items:
INSERT INTO `invoice_order_item` (`order_item_id`, `order_id`, `item_code`, `item_name`, `order_item_quantity`, `order_item_price`, `order_item_final_amount`) VALUES (4100, 2, '13555', 'Face Mask', 120.00, 2000.00, 240000.00), (4101, 2, '34', 'mobile', 10.00, 10000.00, 100000.00), (4102, 2, '34', 'mobile battery', 1.00, 34343.00, 34343.00), (4103, 2, '34', 'mobile cover', 10.00, 200.00, 2000.00), (4104, 2, '36', 'testing', 1.00, 2400.00, 2400.00);
Step2: Implement User Login
First we will create user login functionality to provide invoice manage access to logged in users. We will create login form in index.php.
Build Invoice System with PHP & MySQL
Invoice User Login: