-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread.php
More file actions
33 lines (27 loc) · 997 Bytes
/
read.php
File metadata and controls
33 lines (27 loc) · 997 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
<?php
require_once "db.php";
$stmt = $conn->prepare("SELECT id, title, content FROM notes ORDER BY id DESC");
$stmt->execute();
$result = $stmt->get_result();
?>
<a href="index.php" style="display:inline-block; margin-bottom:15px;">
← Home
</a>
<h3>All Notes</h3>
<?php if ($result->num_rows > 0): ?>
<?php while ($row = $result->fetch_assoc()): ?>
<div style="border:1px solid #ccc; padding:10px; margin-bottom:10px;">
<strong>Title:</strong>
<?= htmlspecialchars($row['title']) ?><br>
<strong>Content:</strong>
<?= nl2br(htmlspecialchars($row['content'])) ?><br><br>
<a href="update.php?id=<?= $row['id'] ?>">Edit</a> |
<a href="delete.php?id=<?= $row['id'] ?>"
onclick="return confirm('Are you sure you want to delete this note?');">
Delete
</a>
</div>
<?php endwhile; ?>
<?php else: ?>
<p>No notes yet. Try adding one.</p>
<?php endif; ?>