-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculate_l.php
72 lines (68 loc) · 1.67 KB
/
calculate_l.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html>
<head>
<title>Bill</title>
<style type="text/css">
table {
width: 50%;
color: #588c7e;
font-family: monospace;
font-size: 25px;
text-align: center;
}
</style>
</head>
<body><center>
<table>
<tr>
<th>Name</th>
<th>Quantity</th>
<th>Cost</th>
<th>Total</th>
</tr>
<?php
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'bill_software';
$con = mysqli_connect($host, $user, $pass, $db);
if($con)
$sql = "SELECT Item_name, Item_quantity, Item_cost, (Item_quantity*Item_cost) as total from bill";
$result = $con -> query($sql);
if($result-> num_rows > 0){
while($row = $result -> fetch_assoc()){
echo "<tr><td>". $row["Item_name"] ."</td><td>". $row["Item_quantity"] ."</td><td>". $row["Item_cost"] ."</td><td>". $row["total"] ." </td></tr>";
}
echo "</table>";
}
echo "</center>";
$sql1 = mysqli_query($con, "SELECT SUM(Item_quantity*Item_cost) as value_sum FROM bill");
$sql2 = mysqli_query($con, "SELECT SUM(Item_quantity*Item_cost)*0.18 as gst_sum FROM bill");
$row = mysqli_fetch_assoc($sql1);
$row2 = mysqli_fetch_assoc($sql2);
$sum = $row['value_sum'];
$sum2 = $row2['gst_sum'];
$sumt = $sum + $sum2;
echo "<center> <br> <br>";
echo "TOTAL COST : ";
echo "$sum";
echo "<br>";
echo "GST : ";
echo "$sum2";
echo "<br>";
echo "TOTAL : ";
echo "$sumt";
echo "</center>";
?>
<CENTER>
<button id="new"
class="button2" >CREATE NEW BILL</button>
<script type="text/javascript">
document.getElementById("new").onclick = function () {
location.href = "bill_software_l.php";
};
</script>
</CENTER>
</table>
</body>
</html>