İçeriğe geç
ShiftDelete.Net
Haber ara/ SDN'ye SorGiriş
Haber Akışı SDNTV İnceleme Forum Yapay Zeka Akıllı Telefon Elektrikli Otomobil Oyun ShiftDelete.Net Global Teknoloji Haberleri Mobil Otomobil Donanım Savunma Bilim Sosyal Medya İnternet Giyilebilir Teknoloji Rehber Ürünler Son dakika Yazarlar
  1. Ana sayfa
  2. Topluluk
  3. Programlama
  4. Web Programlama (PHP, ASP, HTML, CSS, JavaScript)
Web Programlama (PHP, ASP, HTML, CSS, JavaScript)

Php'de Site İçi Aramada Sayfalama Yapma Problemi

mali201217.02.20223 cevap1.225 görüntüleme
2012'den beri157 mesaj
#1
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
<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
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 } ?>
Cevaplar
mali2012 Konuyu açan
2012'den beri157 mesaj
#2
Cevap veren yok mu arkadaşlar. 40 kişi bakmış. :)
2022'den beri2 mesaj
#3
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
2022'den beri2 mesaj
#4
shyam dedi: ↑
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

Cevabını yaz

Cevap yazmak için giriş yap ya da üye ol. Eski forum kullanıcı adın ve parolanla girebilirsin.