· 9 years ago · Jun 20, 2017, 08:12 AM
1<!DOCTYPE>
2<html>
3 <head>
4 <title>Testing</title>
5 <style>
6 table{
7 border: 1px solid black;
8 height: 100px;
9 width: 95%;
10 margin: auto;
11 }
12 tr, th {
13 border: 1px solid black;
14 }
15 </style>
16 </head>
17
18 <body>
19
20 <?php
21 $conn = mysqli_connect('localhost', 'root', '', 'DB');
22/*
23 $sql = "INSERT INTO usr_mainTable ( User, Badge_No, Department, Email, Local)
24 VALUES ('Vinyl Scratch', 'A0001', 'GSS', 'djp@email.com', '1234');";
25 $sql .= "INSERT INTO usr_mainTable ( User, Badge_No, Department, Email, Local)
26 VALUES ('Trixie Lulamoon', 'A0002', 'IS', 'magic@email.com', '2345');";
27 $sql .= "INSERT INTO usr_mainTable ( User, Badge_No, Department, Email, Local)
28 VALUES ('Derpy Hooves', 'A0003', 'HRM', 'derp@email.com', '3456');";
29 $sql .= "INSERT INTO usr_mainTable ( User, Badge_No, Department, Email, Local)
30 VALUES ('Glimmer', 'A0004', 'GSS', 'equal@email.com', '4567s');";
31 $sql .= "INSERT INTO usr_mainTable ( User, Badge_No, Department, Email, Local)
32 VALUES ('Dashie', 'A0005', 'HRM', 'wbfan@email.com', '5678');";
33
34 var_dump($sql);
35
36 $result = mysqli_multi_query($conn, $sql);
37 var_dump($result);
38*/
39 $sql = "SELECT * FROM usr_mainTable;";
40
41/* $sql = "SELECT *
42 FROM inv_mainTable
43 INNER JOIN usr_tempTable
44 ON inv_mainTable.Badge_No = usr_mainTable.Badge_No;";
45*/
46
47 var_dump($sql);
48 $result = mysqli_query($conn, $sql);
49 var_dump($result);
50
51 echo "<table>";
52 if(mysqli_num_rows($result)) {
53 while($row = mysqli_fetch_assoc($result)) {
54 echo "<tr><th> " .
55 $row['id'] . " </th><th> " . $row['User'] . " </th><th> " .
56 $row['Badge_No'] . " </th><th> " . $row['Department'] . " </th><th> " .
57 $row['Email'] . " </th><th> " . $row['Local'] . " </th></tr>" ;
58 }
59 }
60 echo "</table><br />";
61
62 //-------------------------------------------------------------------------------------------------------------------------------
63 class test {
64 public $IS_Cont_No = '1';
65 public $Asset_Type = '';
66 public $Model = '';
67 public $Serial_No = '';
68 public $Remarks = '';
69 public $User = '';
70 public $Badge_No = '';
71 public $Status = '';
72 public $Tag_ID = '';
73 public $Tag_Status = '';
74
75 public function srch () {
76 $q_arr = array();
77 $q_str = $sql_statement = '';
78 $fetch;
79 foreach ($this as $proc_val => $val) {
80 if ($val !== '') {
81 $q_arr [] = $proc_val . " LIKE '%" . $val . "%'";
82 }
83 }
84 $q_str = implode(" AND ", $q_arr);
85
86 $sql_statement = "SELECT * FROM tempTable WHERE " . $q_str;
87 return $sql_statement;
88 }
89 }
90
91 $obj = new test();
92
93 //-------------------------------------------------------------------------------------------------------------------------------
94
95 $sql = "SELECT * FROM usr_tempTable;";
96 // $sql = $obj->srch();
97 var_dump($sql);
98
99 $result = mysqli_query($conn, $sql);
100 var_dump($result);
101
102 echo "<table>";
103 if(mysqli_num_rows($result)) {
104 while($row = mysqli_fetch_assoc($result)) {
105 echo "<tr><th> " .
106 $row['id'] . " </th><th> " . $row['User'] . " </th><th> " .
107 $row['Badge_No'] . " </th><th> " . $row['Department'] . " </th><th> " .
108 $row['Email'] . " </th><th> " . $row['Local'] . " </th></tr>" ;
109 }
110 }
111 echo "</table>";
112
113 $sql = "SELECT * FROM usr_saveTable;";
114 // $sql = $obj->srch();
115 var_dump($sql);
116
117 $result = mysqli_query($conn, $sql);
118 var_dump($result);
119
120 echo "<table>";
121 if(mysqli_num_rows($result)) {
122 while($row = mysqli_fetch_assoc($result)) {
123 echo "<tr><th> " .
124 $row['id'] . " </th><th> " . $row['User'] . " </th><th> " .
125 $row['Badge_No'] . " </th><th> " . $row['Department'] . " </th><th> " .
126 $row['Email'] . " </th><th> " . $row['Local'] . " </th></tr>" ;
127 }
128 }
129 echo "</table>";
130
131 $conn->close();
132 ?>
133
134 </body>
135</html>
136
137
138
139
140-------------------------------------------------------------------------------------------------------------------------------------
141
142
143
144
145<!DOCTYPE>
146<html>
147 <head>
148 <title>Testing</title>
149 <style>
150 table{
151 border: 1px solid black;
152 height: 100px;
153 width: 95%;
154 margin: auto;
155 }
156 tr, th {
157 border: 1px solid black;
158 }
159 </style>
160 </head>
161
162 <body>
163
164 <?php
165 $conn = mysqli_connect('localhost', 'root', '', 'DB');
166/*
167 $sql = "INSERT INTO inv_mainTable (IS_Cont_No, Asset_Type, Model, Serial_No, Remarks, User, Badge_No, Status, Tag_ID, Tag_Status)
168 VALUES ('IS-0000', 'Monitor', 'Samsung', 'ZZZ-56', 'Test', 'Vinyl Scratch', 'A0001', 'Deployed', 'S-00000', 'Completed');";
169 $sql .= "INSERT INTO inv_mainTable (IS_Cont_No, Asset_Type, Model, Serial_No, Remarks, User, Badge_No, Status, Tag_ID, Tag_Status)
170 VALUES ('IS-0001', 'Laptop', 'Sony', 'AABBB', 'Test', 'Trixie Lulamoon', 'A0002', 'Free', 'S-00000', 'Completed');";
171 $sql .= "INSERT INTO inv_mainTable (IS_Cont_No, Asset_Type, Model, Serial_No, Remarks, User, Badge_No, Status, Tag_ID, Tag_Status)
172 VALUES ('IS-0002', 'Network', 'T-LINK', '4444', 'Test', 'Derpy Hooves', 'A0003', 'Defective', 'S-00000', 'Completed');";
173 $sql .= "INSERT INTO inv_mainTable (IS_Cont_No, Asset_Type, Model, Serial_No, Remarks, User, Badge_No, Status, Tag_ID, Tag_Status)
174 VALUES ('IS-0003', 'Desktop', 'Apple', 'kkkk', 'Test', 'Glimmer', 'A0004', 'Reserved', 'S-00000', 'In Progress');";
175 $sql .= "INSERT INTO inv_mainTable (IS_Cont_No, Asset_Type, Model, Serial_No, Remarks, User, Badge_No, Status, Tag_ID, Tag_Status)
176 VALUES ('IS-0004', 'Server', 'Apache', 'this', 'Test', 'Dashie', 'A0005', 'Unaccounted', 'S-00000', 'Not Started');";
177 $sql .= "INSERT INTO inv_mainTable (IS_Cont_No, Asset_Type, Model, Serial_No, Remarks, User, Badge_No, Status, Tag_ID, Tag_Status)
178 VALUES ('IS-0005', 'Desktop', 'Samsung', 'ZZZ-56', 'Test', 'Vinyl Scratch', 'A0001', 'Deployed', 'S-00000', 'Completed');";
179 $sql .= "INSERT INTO inv_mainTable (IS_Cont_No, Asset_Type, Model, Serial_No, Remarks, User, Badge_No, Status, Tag_ID, Tag_Status)
180 VALUES ('IS-0006', 'Workstation', 'Sony', 'AAAAA', 'Test', 'Trixie Lulamoon', 'A0002', 'Free', 'S-00000', 'Completed');";
181 $sql .= "INSERT INTO inv_mainTable (IS_Cont_No, Asset_Type, Model, Serial_No, Remarks, User, Badge_No, Status, Tag_ID, Tag_Status)
182 VALUES ('IS-0007', 'Projector', 'T-LINK', '*&23', 'Test', 'Derpy Hooves', 'A0003', 'Defective', 'S-00000', 'Completed');";
183 $sql .= "INSERT INTO inv_mainTable (IS_Cont_No, Asset_Type, Model, Serial_No, Remarks, User, Badge_No, Status, Tag_ID, Tag_Status)
184 VALUES ('IS-0008', 'Laptop', 'Apple', 'www3', 'Test', 'Glimmer', 'A0004', 'Reserved', 'S-00000', 'In Progress');";
185 $sql .= "INSERT INTO inv_mainTable (IS_Cont_No, Asset_Type, Model, Serial_No, Remarks, User, Badge_No, Status, Tag_ID, Tag_Status)
186 VALUES ('IS-0009', 'UPS', 'Cisco', 'that', 'Test', 'Dashie', 'A0005', 'Unaccounted', 'S-00000', 'Not Started');";
187
188 var_dump($sql);
189
190 $result = mysqli_multi_query($conn, $sql);
191 var_dump($result);
192*/
193 $sql = "SELECT * FROM inv_mainTable;";
194/*
195 $sql = "CREATE TABLE IF NOT EXISTS inv_saveTable (
196 id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
197 IS_Cont_No TEXT,
198 Asset_Type TEXT NOT NULL,
199 Model TEXT NOT NULL,
200 Serial_No TEXT NOT NULL,
201 Remarks TEXT,
202 User TEXT,
203 Badge_No TEXT,
204 Status TEXT NOT NULL,
205 Tag_ID TEXT,
206 Tag_Status TEXT NOT NULL
207 );";
208
209 $sql = "CREATE TABLE IF NOT EXISTS usr_saveTable (
210 id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
211 User TEXT NOT NULL,
212 Badge_No TEXT NOT NULL,
213 Department TEXT NOT NULL,
214 Email TEXT NOT NULL,
215 Local TEXT NOT NULL
216 );";
217
218*/
219/* $sql = "DROP TABLE usr_mainTable; DROP TABLE usr_tempTable; DROP TABLE usr_saveTable;";
220 mysqli_multi_query($conn, $sql);
221*/
222
223 var_dump($sql);
224 $result = mysqli_query($conn, $sql);
225 var_dump($result);
226 var_dump($conn);
227
228 echo "<table>";
229 if(mysqli_num_rows($result)) {
230 while($row = mysqli_fetch_assoc($result)) {
231 echo "<tr><th> " .
232 $row['id'] . " </th><th> " . $row['IS_Cont_No'] . " </th><th> " . $row['Asset_Type'] . " </th><th> " .
233 $row['Model'] . " </th><th> " . $row['Serial_No'] . " </th><th> " . $row['Remarks'] . " </th><th> " .
234 $row['User'] . " </th><th> " . $row['Badge_No'] . " </th><th> " . $row['Status'] . " </th><th> " .
235 $row['Tag_ID'] . " </th><th> " . $row['Tag_Status'] . " </th></tr>" ;
236 }
237 }
238 echo "</table><br />";
239
240 //-------------------------------------------------------------------------------------------------------------------------------
241 class test {
242 public $IS_Cont_No = '1';
243 public $Asset_Type = '';
244 public $Model = '';
245 public $Serial_No = '';
246 public $Remarks = '';
247 public $User = '';
248 public $Badge_No = '';
249 public $Status = '';
250 public $Tag_ID = '';
251 public $Tag_Status = '';
252
253 public function srch () {
254 $q_arr = array();
255 $q_str = $sql_statement = '';
256 $fetch;
257 foreach ($this as $proc_val => $val) {
258 if ($val !== '') {
259 $q_arr [] = $proc_val . " LIKE '%" . $val . "%'";
260 }
261 }
262 $q_str = implode(" AND ", $q_arr);
263
264 $sql_statement = "SELECT * FROM tempTable WHERE " . $q_str;
265 return $sql_statement;
266 }
267 }
268
269 $obj = new test();
270
271 //-------------------------------------------------------------------------------------------------------------------------------
272
273 $sql = "SELECT * FROM inv_tempTable;";
274 // $sql = $obj->srch();
275 var_dump($sql);
276
277 $result = mysqli_query($conn, $sql);
278 var_dump($result);
279
280 echo "<table>";
281 if(mysqli_num_rows($result)) {
282 while($row = mysqli_fetch_assoc($result)) {
283 echo "<tr><th> " .
284 $row['id'] . " </th><th> " . $row['IS_Cont_No'] . " </th><th> " . $row['Asset_Type'] . " </th><th> " .
285 $row['Model'] . " </th><th> " . $row['Serial_No'] . " </th><th> " . $row['Remarks'] . " </th><th> " .
286 $row['User'] . " </th><th> " . $row['Badge_No'] . " </th><th> " . $row['Status'] . " </th><th> " .
287 $row['Tag_ID'] . " </th><th> " . $row['Tag_Status'] . " </th></tr>" ;
288 }
289 }
290 echo "</table>";
291
292 $sql = "SELECT * FROM inv_saveTable;";
293 // $sql = $obj->srch();
294 var_dump($sql);
295
296 $result = mysqli_query($conn, $sql);
297 var_dump($result);
298
299 echo "<table>";
300 if(mysqli_num_rows($result)) {
301 while($row = mysqli_fetch_assoc($result)) {
302 echo "<tr><th> " .
303 $row['id'] . " </th><th> " . $row['IS_Cont_No'] . " </th><th> " . $row['Asset_Type'] . " </th><th> " .
304 $row['Model'] . " </th><th> " . $row['Serial_No'] . " </th><th> " . $row['Remarks'] . " </th><th> " .
305 $row['User'] . " </th><th> " . $row['Badge_No'] . " </th><th> " . $row['Status'] . " </th><th> " .
306 $row['Tag_ID'] . " </th><th> " . $row['Tag_Status'] . " </th></tr>" ;
307 }
308 }
309 echo "</table>";
310
311 $conn->close();
312 ?>
313
314 </body>
315</html>