-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcatalog.php
More file actions
71 lines (63 loc) · 2.03 KB
/
catalog.php
File metadata and controls
71 lines (63 loc) · 2.03 KB
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
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once __DIR__ . '/includes/db_mysqli.php';
$sql = "SELECT dict_id, name FROM dictionaries ORDER BY name ASC";
$result = $conn->query($sql);
$dictionaries = [];
if ($result) {
while ($row = $result->fetch_assoc()) {
$dictionaries[] = $row;
}
} else {
die("Query failed: " . $conn->error);
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dictionary Catalog</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<?php include 'includes/navbar.php'; ?>
<main class="container py-4">
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h3 mb-0">Dictionary Catalog</h1>
<a class="btn btn-primary btn-sm" href="search.php">Go to Search</a>
</div>
<?php if (empty($dictionaries)): ?>
<div class="alert alert-info">No dictionaries yet.</div>
<?php else: ?>
<div class="row g-3">
<?php foreach ($dictionaries as $d): ?>
<div class="col-12 col-md-6 col-lg-4">
<div class="card h-100 shadow-sm">
<div class="card-body">
<h2 class="h5 card-title mb-1">
<?php echo htmlspecialchars($d['name']); ?>
</h2>
<p class="text-muted mb-0">ID: <?php echo (int)$d['dict_id']; ?></p>
</div>
<div class="card-footer bg-transparent">
<a class="btn btn-outline-primary btn-sm"
href="search.php?dict=<?php echo (int)$d['dict_id']; ?>">
Search this dictionary
</a>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</main>
<?php include 'includes/footer.php'; ?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<?php
$conn->close();
?>