2011-06-20 9 views
0

このページネーションは、次の壁紙/以前の壁紙/クエリのみに表示されますが、その空白行も表示されます。 修正方法?ページ分割固定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>"; 
} 

?> 

答えて

0

は、ページ数を把握するようにコードを修正:

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

といただきました次のTODO – Hassan

+0

そのはまだ空の行を示して何 – Hassan

+0

空の行を表示しますか?改ページされた結果、またはページ番号が表示される場所は?あなたは実際の結果のコードを表示していないので、それを助けることはできません。 – GordyD