PHP Invoice Example

PHP Invoice Example

Right now, will make a basic structure to permit a client to pick an item and enter the amount he/she needs to buy and will create an Invoice.

Right now need to make a structure in HTML with the accompanying fields:

  1. Item (utilize a select tag to make a drop-down)
  2. Amount of item

Receipt ought to contain the following:

  1. Sequential number
  2. Item name
  3. Item Picture
  4. Item Rate
  5. Item Quantity
  6. Rebate
  7. Sum
  8. Net (Amount – Discount)

We should begin to take care of this issue:

To make your structure make a record named “product.php” and compose beneath code:

HTML code

<html>
	<form action="bill.php">
		<center>
		<table>
			<caption>
				<font color='blue' size='6'>Select Your Product</font>
			</caption>
			<br><br>
			
			<tr>
			<td>Choose Product:</td>
			<td>
				<select name=prd>
					<option>Product 1</option>
					<option>Product 2</option>
					<option>Product 3</option>
					<option>Product 4</option>
				</select>
			</td>

			<tr>
				<td>Quantity:</td>
				<td><input type=text name=qty></td>
			</tr>

			<tr>
				<td><input type=submit></td>
				<td><input type=reset></td>
			</tr>
			</table>
		<center>
	</form>
</html>

Presently run your PHP record by utilizing URL → ‘localhost/foldername/product.php

You would see your outcome like this:

It’s a great opportunity to make the receipt. Make a record named “bill.php” and include the following code in it:

PHP code with HTML

<html>
	<?php

		$prd=$_GET['prd'];
		$qty=$_GET['qty'];
		$rate=0;
		$img="";
		
		if($prd=="Product 1")
		{
			$rate=400;
			$img='p1.png';
		}
		else if($prd=="Product 2")
		{
			$rate=150;
			$img='p2.jpg';
		}
		else if($prd=="Product 3")
		{
			$rate=50;
			$img='p3.jpg';
		}
		else if($prd=="Product 4")
		{
			$rate=30;
			$img='p4.png';
		}
		$amt=$rate*$qty;
		$dis=$amt*5/100;
		$na=$amt-$dis;
		
	?>
	<center>
	<table border=1 width=70%>
		<caption>
			<font color='blue' size='8'> Invoice</font>
		</caption>
		<br><br>

		<tr>
			<th>S.No</th>
			<th>Description</th>
			<th>Rate</th>
			<th>Qty</th>
			<th>Amount</th>
			<th>Discount</th>
			<th>Net Amount</th>
		</tr>
		
		<tr>
			<td>1</td>
			<td>
				<?php echo "$prd<br><img src=$img width=60 height=60>";?>
			</td>
			<td>
				<?php echo "$rate";?>
			</td>
			<td>
				<?php echo "$qty";?>
			</td>
			<td>
				<?php echo "$amt";?>
			</td>
			<td>
				<?php echo "$dis";?>
			</td>
			<td>
				<?php echo "$na";?>
			</td>
		</tr>
	</table>
	</center>
</html>

This code gets the estimation of amount and item (picked by client), sets a rate and rebate as per the item pick by the client and computes the aggregate sum and net sum. You can supplant the item 1, item 2 … item 4 qualities in HTML structure select tag.

As the client hits the submit button subsequent to picking the item and entering the amount. It will arrive on Invoice page and you would see this way:

Recent Posts

error: Alert: Content is protected!!