-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategories.php
53 lines (46 loc) · 1.78 KB
/
categories.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
45
46
47
48
49
50
51
52
53
<?php
session_start(); // Oturum başlatılıyor
// Kullanıcı giriş yapmamışsa login.php'ye yönlendir
if (!isset($_SESSION['username'])) {
header("Location: login.php");
exit();
}
include 'config.php'; // Veritabanı bağlantısı
// Mevcut kategorileri alıyoruz
$category_stmt = $pdo->query("SELECT * FROM categories ORDER BY name ASC");
$categories = $category_stmt->fetchAll(PDO::FETCH_ASSOC);
include 'header.php';
?>
<div class="container my-5">
<div class="d-flex justify-content-between align-items-center mb-3">
<h2>Kategoriler</h2>
<a href="new_category.php" class="btn btn-success">Yeni Kategori Ekle</a>
</div>
<?php if (count($categories) > 0): ?>
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>Kategori Adı</th>
<th>Telegram Chat ID</th>
<th>Eylemler</th>
</tr>
</thead>
<tbody>
<?php foreach ($categories as $category): ?>
<tr>
<td><?= $category['id'] ?></td>
<td><?= htmlspecialchars($category['name']) ?></td>
<td><?= htmlspecialchars($category['telegram_chat_id']) ?></td>
<td>
<a href="edit_category.php?id=<?= $category['id'] ?>" class="btn btn-warning btn-sm">Düzenle</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="alert alert-warning">Henüz kategori eklenmemiş.</div>
<?php endif; ?>
</div>
<?php include 'footer.php'; ?>