-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
44 lines (36 loc) · 918 Bytes
/
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
40
41
42
43
44
<?php
//including the database connection file
include_once ("config.php");
//fetching data in descending order (lastest entry first)
$query = ("SELECT * FROM users ORDER BY id DESC");
$stmt = $dbConn->prepare($query);
$stmt->execute();
$users = $stmt->fetchAll(PDO::FETCH_OBJ);
?>
<html>
<head>
<title>Homepage</title>
</head>
<body>
<a href="add.html">Add New Data</a><br /><br />
<table width='80%' border=0>
<tr bgcolor='#CCCCCC'>
<td>Name</td>
<td>Age</td>
<td>Email</td>
<td>Update</td>
</tr>
<?php foreach ($users as $user): ?>
<tr>
<td><?= $user->name ?></td>
<td><?= $user->age ?></td>
<td><?= $user->email ?></td>
<td>
<a href="edit.php?id=<?= $user->id ?>">Edit</a> |
<a href="delete.php?id=<?= $user->id ?>" onClick="return confirm('Are you sure you want to delete?')">Delete</a>
</td>
</tr>
<?php endforeach; ?>
</table>
</body>
</html>