first commit
This commit is contained in:
166
en/blog.php
Normal file
166
en/blog.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<?php
|
||||
|
||||
// Set SEO information for the blog homepage
|
||||
$title = "Blog - AI Tools Navigation and Latest AI News - AI Tool Path";
|
||||
$description = "Visit our blog to get the latest AI tools, technology trends, industry insights, and AI news, helping you quickly understand and leverage AI technology.";
|
||||
$keywords = "AI blog, artificial intelligence news, AI tools, AI technology trends, AI industry insights";
|
||||
|
||||
// Include the file that contains SEO tags
|
||||
include('container/links.php');
|
||||
?>
|
||||
|
||||
</head>
|
||||
<body class="body-bg-color">
|
||||
<!-- Header -->
|
||||
<?php include 'container/header.php'; ?>
|
||||
|
||||
<!-- Page Title Start -->
|
||||
<section class="page-title">
|
||||
<div class="container">
|
||||
<div class="page-title__inner">
|
||||
<div class="page-title__shape-1" style="background-image: url(images/shapes/page-title-shape-1.png);"></div>
|
||||
<div class="page-title__title-box">
|
||||
<p class="page-title__sub-title">Blog Post</p>
|
||||
<h3 class="page-title__title">Check Out our Articles it may help to start your AI Journey</h3>
|
||||
</div>
|
||||
<p class="page-title__text">Mastering the Art of AI Tool: Unleashing the Power of <br> Automated Creativity with AI Tool Path</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<style>
|
||||
.active {
|
||||
background: #426bff;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.active a {
|
||||
background: #426bff;
|
||||
color: #fff !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Page Title End -->
|
||||
<!-- Blog Page Start -->
|
||||
<section class="blog-page">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<?php
|
||||
// 安全的分页处理
|
||||
$blogs_per_page = 9; // 设置每页显示的博客数量
|
||||
|
||||
// 获取当前页码,默认为1,并验证为正整数
|
||||
$current_page = isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0 ? (int)$_GET['page'] : 1;
|
||||
|
||||
// 计算查询的起始行
|
||||
$start = ($current_page - 1) * $blogs_per_page;
|
||||
|
||||
// 使用准备语句查询总的博客数目
|
||||
$stmt = $conn->prepare("SELECT COUNT(*) as total FROM blogs WHERE status = ?");
|
||||
$status = 1;
|
||||
$stmt->bind_param("i", $status);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($total_blogs);
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
|
||||
// 计算总页数
|
||||
$total_pages = ceil($total_blogs / $blogs_per_page);
|
||||
|
||||
// 获取当前页面的博客数据
|
||||
$stmt = $conn->prepare("SELECT id, title, image, created_at FROM blogs WHERE status = ? ORDER BY created_at DESC LIMIT ?, ?");
|
||||
$stmt->bind_param("iii", $status, $start, $blogs_per_page);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
// 显示博客
|
||||
while ($blog = $result->fetch_assoc()) {
|
||||
$id = htmlspecialchars($blog['id']);
|
||||
$title = htmlspecialchars($blog['title']);
|
||||
$image_name = htmlspecialchars($blog['image']);
|
||||
$created_at = new DateTime($blog['created_at']);
|
||||
$formatted_date = $created_at->format('d M Y');
|
||||
|
||||
echo "
|
||||
<div class='col-xl-4 col-lg-4 col-md-6'>
|
||||
<div class='blog-page__single'>
|
||||
<div class='blog-page__img-box'>
|
||||
<div class='blog-page__img'>
|
||||
<img src='$image_name' alt='$title'>
|
||||
</div>
|
||||
</div>
|
||||
<h3 class='blog-page__title'>
|
||||
<a href='blog-details?blog=$id'>$title</a>
|
||||
</h3>
|
||||
</div>
|
||||
</div>";
|
||||
}
|
||||
$stmt->close();
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="career-page__pagination mt-5">
|
||||
<ul class="pg-pagination list-unstyled">
|
||||
<?php
|
||||
// 构建分页的基础URL
|
||||
$base_url = "?page=";
|
||||
|
||||
// "Previous" 按钮
|
||||
if ($current_page > 1) {
|
||||
echo '<li class="prev"><a href="' . $base_url . ($current_page - 1) . '" aria-label="Previous"><span class="fas fa-arrow-left"></span></a></li>';
|
||||
}
|
||||
|
||||
if ($total_pages <= 6) {
|
||||
// 如果总页数小于或等于6,显示所有页码
|
||||
for ($page = 1; $page <= $total_pages; $page++) {
|
||||
echo '<li class="count ' . ($page == $current_page ? 'active' : '') . '"><a href="' . $base_url . $page . '">' . $page . '</a></li>';
|
||||
}
|
||||
} else {
|
||||
// 显示前两页
|
||||
echo '<li class="count ' . ($current_page == 1 ? 'active' : '') . '"><a href="' . $base_url . '1">1</a></li>';
|
||||
echo '<li class="count ' . ($current_page == 2 ? 'active' : '') . '"><a href="' . $base_url . '2">2</a></li>';
|
||||
|
||||
// 如果当前页码大于4,显示省略号
|
||||
if ($current_page > 4) {
|
||||
echo '<li class="count"><span>...</span></li>';
|
||||
}
|
||||
|
||||
// 显示中间范围
|
||||
$start_page = max(3, $current_page - 2);
|
||||
$end_page = min($total_pages - 2, $current_page + 2);
|
||||
for ($page = $start_page; $page <= $end_page; $page++) {
|
||||
echo '<li class="count ' . ($page == $current_page ? 'active' : '') . '"><a href="' . $base_url . $page . '">' . $page . '</a></li>';
|
||||
}
|
||||
|
||||
// 如果结束页小于总页数减去2,显示省略号
|
||||
if ($end_page < $total_pages - 2) {
|
||||
echo '<li class="count"><span>...</span></li>';
|
||||
}
|
||||
|
||||
// 显示最后两页
|
||||
echo '<li class="count ' . ($current_page == $total_pages - 1 ? 'active' : '') . '"><a href="' . $base_url . ($total_pages - 1) . '">' . ($total_pages - 1) . '</a></li>';
|
||||
echo '<li class="count ' . ($current_page == $total_pages ? 'active' : '') . '"><a href="' . $base_url . $total_pages . '">' . $total_pages . '</a></li>';
|
||||
}
|
||||
|
||||
// "Next" 按钮
|
||||
if ($current_page < $total_pages) {
|
||||
echo '<li class="next"><a href="' . $base_url . ($current_page + 1) . '" aria-label="Next"><span class="fas fa-arrow-right"></span></a></li>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!-- Blog Page End -->
|
||||
<!-- Free Trail Start -->
|
||||
<?php include 'container/free_trail.php'; ?>
|
||||
<!-- Free Trail End -->
|
||||
<!-- Main Footer Start -->
|
||||
<?php include 'container/footer.php'; ?>
|
||||
<!-- Main Footer End -->
|
||||
<?php include 'container/footer_links.php'; ?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user