Soru Php'de Site İçi Aramada Sayfalama Yapma Problemi

Bu konuyu okuyanlar

mali2012

Asistan
Katılım
10 Eylül 2012
Mesajlar
157
Reaksiyon puanı
9
Puanları
18
Merhabalar. Arkadaşlar, aşağıdaki kodlarla site içi arama yaptığımda çıkan sonuçların sayfalama işlemini yapmaya çalışıyorum. Aradığım kelimeye göre sonuçlar listeleniyor. Ama hepsi 1. sayfada listeleniyor. 2. sayfa ise boş çıkıyor. Kodlar aşağıda, bir bakabilir misiniz?
index.php
HTML:
<div class="arama-alani-div">
<form action="arama.php" method="POST">
<input type="text" name="kelime" placeholder="Arama yap">
<input type="submit">
</form>
</div>

arama.php
PHP:
<?php
if($_POST) {
    $ara = $_POST['kelime'];
    $sayfalamasorgusu = "SELECT * FROM yaziekle WHERE yaziekle_baslik like '%$ara%'";
    $sayfalamasorgu = $db->query($sayfalamasorgusu);
    $sayfasay = $sayfalamasorgu->num_rows;
    if($sayfasay > 0) {
        $sayfa = @$_GET['sayfa'];
        if((empty($sayfa)) or (!is_numeric($sayfa))) { $sayfa = 1; }
        $kacar = 2;
        
        $sayfasayisi = ceil($sayfasay/$kacar);
        $neredenbaslasin = ($sayfa*$kacar)-$kacar;
        $sorgusu = "SELECT * FROM yaziekle ORDER BY yaziekle_id DESC LIMIT $neredenbaslasin, $kacar";
        $sorgu = $db->query($sorgusu);
        foreach($sayfalamasorgu as $sorgu) {
?>

<div class="container-fluid">
    <div class=icerikalani-div>
        <div class="icerik-ic-alani">
            <div class="resim-div">
                <img src="images/eklenenyaziresimleri/<?php echo $sorgu['yaziekle_resim']; ?>">
            </div>

            <div class="baslik-ve-yazi-alani-kategori-ve-devaminioku">
                <div class="yazi-alani-baslik">
                    <?php echo $sorgu['yaziekle_baslik']; ?>
                </div>

                <div class="yazi-alani-yazi">
                    <?php echo nl2br($sorgu['yaziekle_konu']); ?>
                </div>

                <div class="kategori-ve-devaminioku-alani">
                    <div class="yazi-alani-kategori">
                        <?php echo $sorgu['yaziekle_kategori']; ?>
                    </div>

                    <div class="yazi-alani-devaminioku">
                        <a href="devaminioku.php?devam=<?php echo $sorgu['yaziekle_id']; ?>">Devamını Oku</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php } ?>


<?php
    for($i=1; $i<=$sayfasayisi; $i++)
    {
        echo "<a href='arama.php?sayfa={$i}'>{$i}</a>";
    }
?>


<?php } else { echo "0"; } ?>


<?php } ?>
 

mali2012

Asistan
Katılım
10 Eylül 2012
Mesajlar
157
Reaksiyon puanı
9
Puanları
18
Cevap veren yok mu arkadaşlar. 40 kişi bakmış. :)
 

shyam

Öğrenci
Katılım
18 Şubat 2022
Mesajlar
2
Reaksiyon puanı
0
Puanları
1
Yaş
33
EDIT: So I might have gotten some progress now. Changed it all entirely. I have a table, it displays, but when I click next/previous, despite the page in the address bar changing, the contents remain the same. Here is the code:

http://pastie.org/10779862


As the title says, I am new to php. I'm doing okay for only being a week into it though!

Anyways, I have been spending the entire day trying to make pagination for my sql table using tutorials and videos and whatever help I can find on my own, but I am literally stuck with lines 68 and 110 in this.

They keep coming back up with "mysql_fetch_array() expects parameter 1 to be resource, boolean given" and

  1. I have NO IDEA what I am doing wrong
  2. I have NO IDEA how to fix it.
Anyways, looking for a nudge in the right direction and some clarity. Thanks in advance!

http://pastie.org/10779807
 

shyam

Öğrenci
Katılım
18 Şubat 2022
Mesajlar
2
Reaksiyon puanı
0
Puanları
1
Yaş
33
EDIT: So I might have gotten some progress now. Changed it all entirely. I have a table, it displays, but when I click next/previous, despite the page in the address bar changing, the contents remain the same. Here is the code:

http://pastie.org/10779862


As the title says, I am new to php. I'm doing okay for only being a week into it though!

Anyways, I have been spending the entire day trying to make pagination for my sql table using tutorials and videos and whatever help I can find on my own, but I am literally stuck with lines 68 and 110 in this.

They keep coming back up with "mysql_fetch_array() expects parameter 1 to be resource, boolean given" and

  1. omegle I have NO IDEA what I am doing wrong
  2. I have NO IDEA how to fix it.
Anyways, looking for a nudge in the right direction and some clarity. Thanks in advance!

http://pastie.org/10779807
issue got solvedd
 
Üst