-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
150 lines (140 loc) · 5.14 KB
/
test.php
File metadata and controls
150 lines (140 loc) · 5.14 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
147
148
149
150
<html>
<head>
<title>Balance by location</title>
<link rel="stylesheet" type="text/css" href="inventory.css">
</head>
<body>
<h2>Label Team Inventory System</h2>
<ul>
<li><a href="mysqltest.php">Balance</a></li>
<li><a href="addrmv.php">Add</a></li>
<li><a href="update.php">Update</a></li>
<li><a class="active" href="idbyloc.php">Balance by Loc</a></li>
<li><a href="delete.php">Delete</a></li>
<li><a href="export.html">Export</a></li>
</ul>
<form id="addmv" method="POST" action="<?php echo $_SERVER['PHP_SELF']?>" name="update">
<select id="option1" name="option">
<option value="Location" name="location">Location</option>
<option value="SerialNumber" name="serialize">Serial</option>
<!--<option value="ups" name="ups">UPS</option>
<option value="scaner" name="scaner">Scaner</option>
<option value="pc" name="pc">PC</option>
<option value="compimp" name="compimp">Componente Imprimanta</option>
<option value="comppc" name="comppc">Componente PC</option>-->
</select><br>
<input id="loc1" type="text" name="loc"><br>
<input id="sub3" type="submit" name="submit" value="Submit" /><br>
<table class="t1">
<tr id="tr">
<thead>
<th id="th1">Serial Number</th>
<th id="th2">Descriere</th>
<th id="th3">Locatie</th>
<th id="th4">Status</th>
</thead>
</tr>
<?php
$servername = "localhost";
$username = "root";
$password = "Multiread23";
$dbname = "mydb";
//Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
//check connection
if($conn->connect_error){
die("Connection Error: " . $conn->connect_error);
}
echo "Connected succesfully<br>";
//update tables
if(isset($_POST['submit'])){
$option = $_POST['option'];
$location = $_POST['loc'];
$sql_query1 = "SELECT SerialNumber FROM monitor WHERE Location ='".$location."'";
$sql_query2 = "SELECT * FROM compimp WHERE ".$option."='".$location."'";
$sql_query3 = "SELECT * FROM comppc WHERE ".$option."='".$location."'";
$sql_query4 = "SELECT * FROM imprimanta WHERE ".$option."='".$location."'";
$sql_query5 = "SELECT * FROM pc WHERE ".$option."='".$location."'";
$sql_query6 = "SELECT * FROM scaner WHERE ".$option."='".$location."'";
$sql_query7 = "SELECT * FROM ups WHERE ".$option."='".$location."'";
$sql_compare1 = "SELECT SerialNumber FROM monitor WHERE ".$option."='".$location."'";
$result_q1 = $conn->query($sql_query1);
$result_q2 = $conn->query($sql_query2);
$result_q3 = $conn->query($sql_query3);
$result_q4 = $conn->query($sql_query4);
$result_q5 = $conn->query($sql_query5);
$result_q6 = $conn->query($sql_query6);
$result_q7 = $conn->query($sql_query7);
$result_compare1 = $conn->query($sql_compare1);
while($row_1 = $result_q1->fetch_assoc()){
echo "<tr>
<th>" . $row_1["SerialNumber"]."<br><input id='compare_1' type='text' name='compare_1'></th>".
"<th>" . $row_1["Descriere"]. "</th>".
"<th>" . $row_1["Location"]. "</th>".
"<th>" . $row_1["Status"]. "</th></tr>" ;
continue;
}
while($row_2 = $result_q2->fetch_assoc()){
echo "<tr>
<th>" . $row_2["SerialNumber"]."<br><input id='compare_2' type='text' name='compare_2'></th>".
"<th>" . $row_2["Descriere"]. "</th>".
"<th>" . $row_2["Location"]. "</th>".
"<th>" . $row_2["Status"]. "</th></tr>" ;
continue;
}
while($row_3 = $result_q3->fetch_assoc()){
echo "<tr>
<th>" . $row_3["SerialNumber"]."<br><input id='compare_3' type='text' name='compare_3'></th>".
"<th>" . $row_3["Descriere"]. "</th>".
"<th>" . $row_3["Location"]. "</th>".
"<th>" . $row_3["Status"]. "</th></tr>" ;
continue;
}
while($row_4 = $result_q4->fetch_assoc()){
echo "<tr>
<th>" . $row_4["SerialNumber"]."<br><input id='compare_4' type='text' name='compare_4'></th>".
"<th>" . $row_4["Descriere"]. "</th>".
"<th>" . $row_4["Location"]. "</th>".
"<th>" . $row_4["Status"]. "</th></tr>" ;
continue;
}
while($row_5 = $result_q5->fetch_assoc()){
echo "<tr>
<th>" . $row_5["SerialNumber"]."<br><input id='compare_5' type='text' name='compare_5'></th>".
"<th>" . $row_5["Descriere"]. "</th>".
"<th>" . $row_5["Location"]. "</th>".
"<th>" . $row_5["Status"]. "</th></tr>" ;
continue;
}
while($row_6 = $result_q6->fetch_assoc()){
echo "<tr>
<th>" . $row_6["SerialNumber"]."<br><input id='compare_6' type='text' name='compare_6'></th>".
"<th>" . $row_6["Descriere"]. "</th>".
"<th>" . $row_6["Location"]. "</th>".
"<th>" . $row_6["Status"]. "</th></tr>" ;
continue;
}
while($row_7 = $result_q7->fetch_assoc()){
echo "<tr>
<th>" . $row_7["SerialNumber"]."<br><input id='compare_7' type='text' name='compare_7'></th>".
"<th>" . $row_7["Descriere"]. "</th>".
"<th>" . $row_7["Location"]. "</th>".
"<th>" . $row_7["Status"]. "</th>".
"<input id='sub4' type='submit' name='submit_1' value='Submit' /><br>" ;
continue;
}
while($row_8 = $result_compare1->fetch_assoc()){
$string = join(',', $row_8);
foreach($row_8 as $key => $value){
$string .= ",$value";
}
//$string = substr($string, 1);
echo $string;
//print_r($row_8);
}
}
$conn->close();
?>
</div>
</body>
</html>