- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
$number_of_posts = 1;
$page_id = $_GET['page'];
$all_posts_query = "SELECT * FROM `posts` WHERE status = 'publish'";
$all_posts_run = mysqli_query($con, $all_posts_query);
$all_posts = mysqli_num_rows($all_posts_run);
$total_pages = ceil($all_posts / $number_of_posts);
$posts_start_from = ($page_id - 1) * $number_of_posts;
$query = "SELECT * FROM `posts` WHERE `status` = 'publish' ORDER BY id DESC LIMIT $posts_start_from, $number_of_posts";