File manager - Edit - /home/webapp68.cm.in.th/u68319090003/Final/Final/admin/manage_articles.php
Back
<?php session_start(); if (!isset($_SESSION['user_id']) || ($_SESSION['role'] != 'admin' && $_SESSION['role'] != 'teacher')) { header("Location: ../login.php"); exit(); } include(__DIR__ . '/../config/db.php'); // ดึงข่าวทั้งหมด พร้อมชื่อหมวด $sql = "SELECT a.id, a.title, a.slug, a.status, a.created_at, c.name AS category_name FROM articles a JOIN categories c ON a.category_id = c.id ORDER BY a.created_at DESC"; $articles = $conn->query($sql); ?> <!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <title>จัดการข่าว</title> <link href="https://fonts.googleapis.com/css2?family=Prompt:wght@400;600&display=swap" rel="stylesheet"> <style> * { margin:0; padding:0; box-sizing:border-box; font-family:'Prompt', sans-serif; } body { background:#f2f6fc; color:#333; } /* Header */ .header { background: linear-gradient(90deg, #667eea, #764ba2); color:#fff; padding:20px; text-align:center; border-bottom-left-radius:20px; border-bottom-right-radius:20px; box-shadow:0 4px 15px rgba(0,0,0,0.2); } .header h2 { font-size:26px; margin-bottom:5px; } .header p { font-size:15px; } .header a.logout { color:#fff; background:#ff4d4f; padding:6px 15px; border-radius:20px; margin-left:10px; text-decoration:none; font-size:14px; transition:0.3s; } .header a.logout:hover { background:#d9363e; } /* Container */ .container { max-width:1100px; margin:30px auto; padding:0 15px; } /* Top Actions */ .top-links { text-align:right; margin-bottom:20px; } .top-links a { display:inline-block; padding:10px 18px; background:linear-gradient(45deg,#42a5f5,#478ed1); color:#fff; text-decoration:none; border-radius:30px; font-size:15px; font-weight:600; transition: all 0.3s; } .top-links a:hover { transform:scale(1.05); } /* Table */ table { width:100%; border-collapse:separate; border-spacing:0 12px; } th { text-align:left; padding:12px; background:#e3eafc; font-weight:600; color:#444; border-radius:8px; } td { background:#fff; padding:14px 12px; box-shadow:0 2px 6px rgba(0,0,0,0.08); border-radius:8px; vertical-align:middle; } tr:hover td { background:#f9fbff; } /* Buttons */ .btn { padding:8px 14px; border-radius:25px; color:#fff; text-decoration:none; font-size:14px; transition:0.3s; display:inline-block; } .edit { background:#28a745; } .edit:hover { background:#218838; } .delete { background:#e74c3c; } .delete:hover { background:#c0392b; } /* Responsive */ @media(max-width:768px){ table, thead, tbody, th, td, tr { display:block; width:100%; } th { display:none; } td { margin-bottom:12px; padding:12px; box-shadow:0 2px 5px rgba(0,0,0,0.1); } td:before { content: attr(data-label); font-weight:600; display:block; margin-bottom:6px; color:#555; } } </style> </head> <body> <div class="header"> <h2>ระบบจัดการข่าว</h2> <p>สวัสดี, <?php echo htmlspecialchars($_SESSION['username']); ?> <a href="../admin/logout.php" class="logout">ออกจากระบบ</a> </p> </div> <div class="container"> <div class="top-links"> <a href="add_article.php">+ เพิ่มข่าวใหม่</a> </div> <table> <thead> <tr> <th>ID</th> <th>หัวข้อข่าว</th> <th>หมวดข่าว</th> <th>สถานะ</th> <th>วันที่สร้าง</th> <th>จัดการ</th> </tr> </thead> <tbody> <?php while($row = $articles->fetch_assoc()): ?> <tr> <td data-label="ID"><?php echo $row['id']; ?></td> <td data-label="หัวข้อข่าว"><?php echo htmlspecialchars($row['title']); ?></td> <td data-label="หมวดข่าว"><?php echo htmlspecialchars($row['category_name']); ?></td> <td data-label="สถานะ"><?php echo $row['status']; ?></td> <td data-label="วันที่สร้าง"><?php echo $row['created_at']; ?></td> <td data-label="จัดการ"> <a class="btn edit" href="edit_article.php?id=<?php echo $row['id']; ?>">แก้ไข</a> <a class="btn delete" href="delete_article.php?id=<?php echo $row['id']; ?>" onclick="return confirm('ยืนยันลบข่าวนี้?')">ลบ</a> </td> </tr> <?php endwhile; ?> </tbody> </table> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.43 |
proxy
|
phpinfo
|
Settings