-
Notifications
You must be signed in to change notification settings - Fork 224
/
index.php
39 lines (36 loc) · 1.01 KB
/
index.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
<?php
// Include the database connection file
require_once("dbConnection.php");
// Fetch data in descending order (lastest entry first)
$result = mysqli_query($mysqli, "SELECT * FROM users ORDER BY id DESC");
?>
<html>
<head>
<title>Homepage</title>
</head>
<body>
<h2>Homepage</h2>
<p>
<a href="add.php">Add New Data</a>
</p>
<table width='80%' border=0>
<tr bgcolor='#DDDDDD'>
<td><strong>Name</strong></td>
<td><strong>Age</strong></td>
<td><strong>Email</strong></td>
<td><strong>Action</strong></td>
</tr>
<?php
// Fetch the next row of a result set as an associative array
while ($res = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>".$res['name']."</td>";
echo "<td>".$res['age']."</td>";
echo "<td>".$res['email']."</td>";
echo "<td><a href=\"edit.php?id=$res[id]\">Edit</a> |
<a href=\"delete.php?id=$res[id]\" onClick=\"return confirm('Are you sure you want to delete?')\">Delete</a></td>";
}
?>
</table>
</body>
</html>