forked from RAI-ADF/RAI_Task_4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoadDataUserPage.php
More file actions
56 lines (49 loc) · 996 Bytes
/
LoadDataUserPage.php
File metadata and controls
56 lines (49 loc) · 996 Bytes
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
<!DOCTYPE html>
<html>
<head>
<style>
table {
width: 100%;
border-collapse: collapse;
}
table, td, th {
border: 1px solid black;
padding: 5px;
}
th {text-align: left;}
</style>
</head>
<body>
<?php
$q = intval($_GET['q']);
$con = mysqli_connect('localhost','root','','task4');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"ajax_demo");
if($q == null) {
$sql="SELECT * FROM inventory";
}else{
$sql="SELECT * FROM 'inventory' WHERE username = '".$q."'";
}
$result = mysqli_query($con,$sql);
echo "<table>
<tr>
<th>ID</th>
<th>Username</th>
<th>Name</th>
<th>Total</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['total'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
</body>
</html>