This repository has been archived by the owner on Feb 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.php
97 lines (82 loc) · 3.73 KB
/
users.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>User List | Admin | FoodHub</title>
<link href="logo.jpg" rel="icon" />
</head>
<body>
<?php
include 'config.php';
?>
<h3>FoodHub User List</h3>
<br>
<a href="index.php">Go Back</a> | <a href="adduser.php">Add User</a> | <a href="../logout.php">Log Out</a>
<br>
<br>
<input type="search" id="searchbox">
<input type="button" value="Search" id="searchbtn">
<br>
<script>
var srcbtn = document.getElementById('searchbtn');
srcbtn.addEventListener('click', searchprocess);
function searchprocess() {
var searchvalue = document.getElementById('searchbox').value;
window.location.assign("searchpage.php?param1=" + searchvalue);
}
</script>
<table>
<thead>
<tr>
<th>ID</th>
<th>User Name</th>
<th>Email</th>
<th>Phone</th>
<th>Type</th>
<th>Address</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
try{
$dbcon = new PDO("mysql:host=$dbserver:$dbport;dbname=$db;","$dbuser","$dbpass");
$dbcon->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sqlquery="SELECT * FROM usertable";
try{
$returnval=$dbcon->query($sqlquery); ///PDO Statement
$logintable=$returnval->fetchAll();
foreach($logintable as $row){
?>
<tr>
<td><?php echo $row['user_id'] ?></td>
<td><?php echo $row['username'] ?></td>
<td><?php echo $row['user_email'] ?></td>
<td><?php echo $row['user_phone'] ?></td>
<td><?php echo $row['user_type'] ?></td>
<td><?php echo $row['user_address'] ?></td>
<td><a href="edituser.php?id=<?php echo $row['user_id'] ?>">Edit</a> | <a href="deleteuser.php?id=<?php echo $row['user_id'] ?>">Delete</a></td>
</tr>
<?php
}
}
catch(PDOException $ex){
?>
<tr>
<td colspan="6">Data read error ... ...</td>
</tr>
<?php
}
}
catch(PDOException $ex){
?>
<tr>
<td colspan="6">Data read error ... ...</td>
</tr>
<?php
}
?>
</tbody>
</table>
</body>
</html>