簡體   English   中英

分頁修復PHP MySQL的

[英]pagination fixing php mysql

此分頁僅適用於下一個和上一個牆紙/查詢,但它也顯示空白行,如何解決?

<?php 

// Figure out the limit for the query based 
// on the current page number. 
$from = (($walpaperid * $max_results) - $max_results);  

// Figure out the total number of results in DB: 
$total_results = mysql_result(mysql_query("SELECT COUNT( * ) AS `Rows` , `wallpaperid` 
                 FROM `wallpaper` ORDER BY `wallpaper`.`wallpaperid` ASC"),0) or die(mysql_error()); 

// Figure out the total number of pages. Always round up using ceil() 
$total_pages = ceil($from / $max_results); 

// Build Page Number Hyperlinks 

// Build Previous Link 
if($wallpaperid > 1){ 
    $prev = ($wallpaperid - 1); 
        echo "<a href=\"edit-delete-wallpaper.php?wallpaperid=$prev\">&lt;Previous Page</a>&nbsp;";  
} 

for($i = 1; $i <= $total_pages; $i++){ 
    if(($pagenum) == $i){ 
        echo "<strong>$i</strong> "; 
    } else { 
            echo "<a class = 'mlnk' href=\"$siteurl3/$cat_url-$catid-$i.php\">$i</a> |";

    } 
} 

// Build Next Link 
if($wallpaperid < $total_pages){ 
    $next = ($wallpaperid + 1); 

     echo "<a href=\"edit-delete-wallpaper.php?wallpaperid=$next\">Next Page&gt;</a>"; 
} 

?>

更正您的代碼以找出頁數:

$total_pages = ceil($total_results / $max_results); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM