Tekil Mesaj gösterimi
Alt 27 Kasım 2007, 11:09   #4
Nickolas
Guest
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Yüzdesi:(%)
Cevap: Bir kaç sorun.




3. Sorun içinde... Sana kendi yazdığım ve kullandığım hazır Sayfalama tekniklerini vereyim...

Kod:   Kodu kopyalamak için üzerine çift tıklayın!
<?php // Burada Bir sayfada Gösterilebilecek Maksimum Sonuç Sayısı ve Standard Sonuç sayısını ayarlayabilirsiniz. // 1. Parametre: Şuan Aktif sayfa.. // 2. Parametre: 1 Sayfada Gösterilecek Sonuç sayısı... // 3. Parametre: Toplam SQL Sonucu.. // 4. Parametre (isteğe göre): 1 Sayfada gösterilebilecek Maksimum Sonuç Sayısı.. // 5. Parametre (isteğe göre): 1 Sayfada gösterilebilecek Standard Sonuç sayısı.. function sanitize_pageresult(&$page, &$perpage, $totalresult, $maxperpage = 20, $defaultperpage = 20) { if ($perpage < 1) { $perpage = $defaultperpage; } if ($perpage > $maxperpage) { $perpage = $maxperpage; } $totalpage = ceil($totalresult / $perpage); if ($page > $totalpage) { $page = $totalpage; } if ($page < 1) { $page = 1; } return $totalpage; } // Sayfa, 1 Sayfada Gösterilecek Sonuç sayısı ve Toplam Sonuca göre ortaya çıkan SQL Limiti... function fetch_sql_limit($page, $perpage, $totalresult) { $limitlower = ($page - 1) * $perpage + 1; $limitupper = $page * $perpage; if ($limitupper > $totalresult) { $limitupper = $totalresult; if ($limitlower > $totalresult) { $limitlower = $totalresult - $perpage; } } if ($limitlower <= 0) { $limitlower = 1; } return ($limitlower - 1); } // Örnek: $page = intval($_GET['p']); $perpage = intval($_GET['pp']); $totalresult_resource = mysql_query("SELECT COUNT(*) AS count FROM table"); // Toplam Sonuç Sayısı $totalresult = mysql_fetch_array($totalresult_resource, MYSQL_ASSOC); $totalresult = $totalresult['count']; $totalpage = sanitize_pageresult($page, $perpage, $totalresult, 100); // 1 Sayfada Maksimum 100 Sonuç Görüntülenebilir olan Toplam Sayfa sayısı $limit = fetch_sql_limit($page, $perpage, $totalresult); // SQL 'de Kullanacağımız Limit değer... $sqlres = mysql_query("SELECT * FROM table LIMIT $limit, $perpage"); // LIMIT Kısmı Biraz önce Bulduğumuz Limit değer ve 1 Sayfada Gösterilecek Sayfa Sayısı ile ilişkilidir. while ($result = mysql_fetch_array($sqlres, MYSQL_ASSOC)) { // Sonuç Listeleme } if ($totalpage > 1) { echo "<div style=\"margin-top: 10px;\">"; for ($i = 1; $i <= $totalpage; $i++) { echo "<a href=\"page.php?p=$i" . ($perpage ? "&pp=$perpage" : "") . "\">[ $i ]</a>"; } echo "</div>"; } ?>


 
Alıntı ile Cevapla

IRCForumlari.NET Reklamlar
sohbet odaları reklam ver Benimmekan Mobil Sohbet