query("SELECT COUNT(*) as total FROM blogs"); $totalBlogs = $countQuery->fetch_assoc()['total']; $totalPages = ceil($totalBlogs / $limit); /* Fetch Blogs */ $blogs = $conn->query(" SELECT * FROM blogs ORDER BY id DESC LIMIT $limit OFFSET $offset "); ?>