Bir site kodluyorum ama bir sıkıntı ortaya çıktı.
yukardaki kodlarda sayfalama yaptırmak için yazdım ama sitede bir sürü daha fazla yükle sayısı çıktı bunu nasıl tek hale getirebiliriz acaba ?
Tüm kodlar bunlar, nerede hata yapıyorum acaba ?
$number_of_posts = 2;
if(isset($_GET['page'])){
$page_id = $_GET['page'];
}
else{
$page_id = 1;
}
if(isset($_GET['cat'])){
$cat_id = $_GET['cat'];
$cat_query = "SELECT * FROM categories WHERE id = $cat_id";
$cat_run = mysqli_query($con, $cat_query);
$cat_row = mysqli_fetch_array($cat_run);
$cat_name = $cat_row['category'];
}
$all_posts_query = "SELECT * FROM posts WHERE status = 'publish'";
if(isset($cat_name)){
$all_posts_query .= " and categories = '$cat_name'";
}
$all_posts_run = mysqli_query($con, $all_posts_query);
$all_posts = mysqli_num_rows($all_posts_run);
$totalpages = ceil($all_posts / $number_of_posts);
$posts_start_from = ($page_id - 1) * $number_of_posts;
?>
$slider_query = "SELECT * FROM posts WHERE slider = 'yes' ORDER BY id DESC LIMIT 3";
$slider_run = mysqli_query($con, $slider_query);
if(mysqli_num_rows($slider_run) > 0){
?>
$check = 0;
while($slider_row = mysqli_fetch_array($slider_run)){
$slider_id = $slider_row['id'];
$slider_date = getdate($row['date']);
$slider_day = $slider_date['mday'];
$slider_month = $slider_date['month'];
$slider_year = $slider_date['year'];
$slider_title = $slider_row['title'];
$slider_image = $slider_row['image'];
$slider_author = $slider_row['author'];
$slider_author_image = $slider_row['author_image'];
$slider_categories = $slider_row['categories'];
$check = $check + 1;
if($check == 1){
echo "
Yayınlanan Haberler
$query = "SELECT * FROM posts WHERE status = 'publish'";
if(isset($cat_name)){
$query .= " and categories = '$cat_name'";
}
$query .= "ORDER BY id DESC LIMIT $posts_start_from, $number_of_posts";
$run = mysqli_query($con,$query);
if(mysqli_num_rows($run) > 0){
while($row = mysqli_fetch_array($run)){
$id = $row['id'];
$date = getdate($row['date']);
$day = $date['mday'];
$month = $date['month'];
$year = $date['year'];
$title = $row['title'];
$author = $row['author'];
$author_image = $row['author_image'];
$categories = $row['categories'];
$tags = $row['tags'];
$post_data = $row['post_data'];
$views = $row['views'];
$status = $row['status'];
$image = $row['image'];
?>
}
}
else{
echo "Hiçbir Haber Yazısı Mevcut Değil :(
";
}
?>
<script></script>
<script></script>
<script></script>
<script></script>
<script>
//Owl carousel initializing
$('#postCarousel').owlCarousel({
loop:true,
dots:true,
nav:false,
navText: ['',''],
items:1,
})
//widget carousel initialize
$('#widgetCarousel').owlCarousel({
dots:true,
nav:false,
items:1
})
</script>