Showing posts with label inventory system in php and mysql. Show all posts
Showing posts with label inventory system in php and mysql. Show all posts

Thursday, June 26, 2014

Inventory System in PHP and MySQL

One of the most commonly used business application software is called Inventory System. This type of software was designed primarily to monitor the in and outs of products, it also designed to generated reports and inform the user how many products left in the storage so the they can make an order again to replenish the product in their stock room for example.

This simple inventory system will show you the name of the product, the quantity, the individual cost and the total cost. It also sum up all the cost of all products from the database. I just wrote this code just to learn how to perform computation of values in the fields in the table without using looping statements just like For loop I'm just using SQL commands to accomplish the task. One of the things that I have discovered is the SQL statements are very easy to use and can accomplish most business operations and simple calculations with ease.

I am using PHP and MySQL as my tools in creating this Inventory System application this is not yet a complete application there are still many things that can improve I just want to show everyone how to make this application with a few commands in PHP and MySQL. I hope you will find my work useful in your programming projects in the future.

Thank you very much.

Sample Output of our Program


Program Listing

<?php
// Written By: Mr. Jake R. Pomperada, MAED-IT
// Date : June 26, 2014
// PHP and MySQL

$con=mysqli_connect("localhost","root","","values");

if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * , val_1 * val_2 AS  'total' FROM solve");
echo "\n\n";
echo "<table border='1'>
<tr>
<th align='center'>Product Name</th>
<th align='center'>Price</th>
<th align='center'>Quantity</th>
<th align='center'>Total Cost</th>
</tr>";

while($row = mysqli_fetch_array($result)) {
  echo "<tr>";
  echo "<td align='center'>" . $row['prod_name'] . "</td>";
  echo "<td align='center'>" . $row['val_1'] . "</td>";
  echo "<td align='center'>" . $row['val_2'] . "</td>";
  echo "<td align='center'> " . $row['total'] . "</td>";
  echo "</tr>";
}
echo "</table>";
$result_sum = mysqli_query($con,"SELECT * , SUM(val_1*val_2) AS  'total_sum' FROM solve");
echo "\n\n";
while($row = mysqli_fetch_array($result_sum)) {

echo "<h2> Total Cost  => Php ";

$solve = $row['total_sum'];
echo  number_format($solve,2);
echo "</h2";

}
mysqli_close($con);
?>