-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.php
33 lines (32 loc) · 900 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
<?php
// Include the database connection file
include_once("config.php");
// Fetch contacts (in descending order)
$result = mysqli_query($mysqli, "SELECT * FROM contacts ORDER BY id DESC");
?>
<html>
<head>
<title>MariaDB Rolodex</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<table>
<tr>
<td>Name</td>
<td>Age</td>
<td>Email</td>
<td><a class="button" href="add.php">Add Contact</a></td>
</tr>
<?php
// Print contacts
while($res = mysqli_fetch_array($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 this contact?')\">Delete</a></td>";
}
?>
</table>
</body>
</html>