-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomp.php
More file actions
146 lines (88 loc) · 2.7 KB
/
comp.php
File metadata and controls
146 lines (88 loc) · 2.7 KB
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
<?php session_start(); ?>
<!DOCTYPE HTML>
<html>
<?php
include 'stuhead.php';
include 'db.php';
$labid=$_GET['id'];
?>
<head>
<title>Request</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>
<fieldset>
<legend align="center" ><h2> REQUEST FORM </h2></legend>
<center>
<form method="post" action="">
<?php
// Create connection
// Check connection
$sql = "SELECT * FROM consumable where labId='$labid' ORDER BY family";
$result = mysqli_query($con,$sql);
echo "<br><center> Components </center> ";
if (mysqli_num_rows($result) > 0) {
echo "<br>";
while($row = mysqli_fetch_assoc($result)){
echo "<h4> " .$row['family']. "<h4> " .$row['value']. "<h4> " .$row['unit']. "<h4> <input type='number' name=".$row['compId']." min='0' placeholder='0 if not required'> <br>";
//echo "DURATION IN HOURS: <input type='number' name='number[]' min='0'> <br>";
echo "<br>";
}
} else {
echo "RECORD NOT FOUND";
exit;
}
?>
</H3>
<input type="submit" name="sub">
</form>
</fieldset>
</center>
<?php
if(isset($_POST['sub'])){
// Create $connection
// set parameters and execute
$sql1 = "SELECT MAX(RequestNo) FROM request";
$result1 = mysqli_query($con,$sql1);
$row1 = mysqli_fetch_assoc($result1);
$requestno = $row1['MAX(RequestNo)'] + 1;
$sql3 = "SELECT * FROM consumable ";
$result3 = mysqli_query($con,$sql3);
if (mysqli_num_rows($result3) > 0) {
echo "<br><br>";
while($row = mysqli_fetch_assoc($result3)){
//echo "<h4> " .$row['name']. "</h4>";
if($_POST[$row['compId']] > 0)
{
$status="New";
$compid=$row['compId'];
$number=$_POST[$row['compId']];
$rollno=$_SESSION['rollno'];
$stmt = "INSERT INTO request (rollno, labId, RequestNo, status, compId, number) VALUES ('$rollno', '$labid', '$requestno', '$status', '$compid', '$number')";
// set parameters and execute
mysqli_query($con,$stmt);
$subject = 'Request for component';
$comment = " " .$rollno. " is requesting for comp: " .$compid. " with Quantity ".$number. " ";
$query = " INSERT INTO comment_sta VALUES (NULL,'1','$labid','$subject','$comment','0',NULL) ";
$result54= mysqli_query($con, $query);
}
}
}
else {
echo "RECORD NOT FOUND";
exit();
}
mysqli_close();
echo "<script> window.open('lab.php', '_self');</script>";
}
?>
<script>
function selects()
{
document.getElementById("srequest").className = "selected";
}
</script>
</body>
</html>