-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmontexp.php
151 lines (124 loc) · 3.09 KB
/
montexp.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php session_start();
$l=$_SESSION['labid'];
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Expense</title>
<meta name="description" content="website description" />
<meta name="keywords" content="website keywords, website keywords" />
<meta http-equiv="content-type" content="text/html; charset=windows-1252" />
<link rel="stylesheet" type="text/css" href="style/style.css" />
</head>
<style type="text/css">
table {
background-color: #00C6F0;
color: white;
width: 80%;
height: 75%;
}
input[type=submit] {
width: 80%%;
background-color: #00C6F0;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 10px;
cursor: pointer;
}
input[type=submit]:hover {
background-color: #00bbe6;
}
</style>
<?php
include 'newhead.php';
include 'db.php';
?>
<div id="content">
<!-- insert the page content here -->
<?php
echo "<h2>Requests</h2>";
$sql = "SELECT * FROM bill";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0)
{
echo "<center>";
echo "<table>
<tr>
<th>billID</th>
<th>Date</th>
<th>Description</th>
<th>cost</th>
</tr> ";
echo"</center>";
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
$billID=$row['billID'];
$date=$row['date'];
$description=$row['description'];
$cost= $row['cost'];
echo " <div id='movie_box' class='dashdiv'>";
echo "<tr>";
echo "<td align='center'>".$billID."</td>";
echo "<td align='center'>".$date."</td>";
echo "<td align='center'>".$description."</td>";
echo "<td align='center'>".$cost."</td>";
echo "</tr>";
echo "</div>";
}
}
else {
echo "No requests";
} ?>
<center>
<fieldset>
<legend align="center" ><h2> BILL FORM </h2></legend><hr>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
SELECT MONTH : <input type = "month" name = "from" > <br> <br>
<input type="submit" name="GetExpense" value="Get Expense">
</form>
</fieldset>
</center>
<?php
mysqli_close($con);
$sum='0';
if($_SERVER["REQUEST_METHOD"] == "POST"){
$servername = "localhost";
$username = "root";
$password = "time.org";
$dbname = "component_distribution";
// Create $connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$from = $_POST["from"];
$from .= "-01";
$to = $_POST["from"];
$to .= "-31";
$month = $_POST["from"];
$sql3 = "SELECT SUM(cost) FROM bill WHERE MONTH(date)='$month' AND labId='$l'";
$result3 = $conn->query($sql3);
if ($result3->num_rows > 0) {
while($row = $result3->fetch_assoc()){
echo "<br><br>";
$sum =$sum+$row["SUM(cost)"];
echo "<i><b><center>Total Expense for '$month' is Rs. '$sum' </center></b></i>";
echo "<br> <br>";
}
}
$conn->close();
}
?>
</div>
</div>
</body>
<script>
function selects()
{
document.getElementById("montexp").className = "selected";
}
</script>
</html>