AIPT/cms_admin/blog_view.php

93 lines
4.6 KiB
PHP
Raw Normal View History

2024-10-29 11:42:53 +08:00
<?php include('container/security.php'); ?>
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
<!-- head links start -->
<?php include 'container/head_links.php';?>
<!-- head links start -->
</head>
<body>
<!-- side_bar start -->
<?php include 'container/side_bar.php' ?>
<!-- side_bar end -->
<main class="dashboard-main">
<!-- Header start -->
<?php include 'container/header.php' ?>
<div class="dashboard-main-body">
<div class="d-flex flex-wrap align-items-center justify-content-between gap-3 mb-24">
<h6 class="fw-semibold mb-0">AI Tool Products</h6>
<ul class="d-flex align-items-center gap-2">
<a href="blog_add" class="btn btn-primary">+ Add Blog</a>
</ul>
</div>
<div class="card basic-data-table">
<div class="card-header">
<h5 class="card-title mb-0">All Products List</h5>
</div>
<div class="card-body">
<table class="table bordered-table mb-0" id="dataTable" data-page-length='10'>
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Image</th>
<th scope="col">Title</th>
<th scope="col">Description</th>
<th scope="col">Status</th> <!-- 添加Status列 -->
<th scope="col">Created At</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<?php
// Fetch blog entries
$result = mysqli_query($conn, "
SELECT * FROM blogs
");
$i = 1;
while ($row = mysqli_fetch_assoc($result)) {
$blog_id = $row['id'];
$blog_title = htmlspecialchars($row['title']);
$blog_image = htmlspecialchars($row['image']);
$description = htmlspecialchars($row['description']);
$created_at = htmlspecialchars($row['created_at']);
$status = $row['status'] == 1 ? '上架' : '未上架'; // 判断status状态
echo "
<tr>
<td>$i</td>
<td><img src='$blog_image' alt='Blog Image' class='img-thumbnail' style='width: 50px; height: auto;'></td>
<td><span>$blog_title</span></td>
<td><textarea readonly class='form-control' rows='3'>$description</textarea></td>
<td>$status</td> <!-- 显示Status -->
<td>$created_at</td>
<td>
<a href='blog_edit.php?id=$blog_id' class='w-32-px h-32-px bg-success-focus text-success-main rounded-circle d-inline-flex align-items-center justify-content-center'>
<iconify-icon icon='lucide:edit'></iconify-icon>
</a>
<a href='blog_delete.php?id=$blog_id' class='w-32-px h-32-px bg-danger-focus text-danger-main rounded-circle d-inline-flex align-items-center justify-content-center' onclick='return confirm(\"Are you sure you want to delete this blog?\");'>
<iconify-icon icon='mingcute:delete-2-line'></iconify-icon>
</a>
</td>
</tr>";
$i++;
}
mysqli_close($conn);
?>
</tbody>
</table>
</div>
</div>
</div>
<?php include 'container/footer.php' ?>
</main>
<!-- Footer Links Start -->
<?php include 'container/footer_links.php' ?>
<script>
let table = new DataTable('#dataTable');
</script>
</body>
</html>