babacpiran
New Member
اشکال این کد در کجاست که شمارش بعضی صفحه را نشون می ده و بعضی صفحه را نشون نمی ده
PHP:
<?php
$counts=0;
$total_pages = ceil($num_posts/$per_page);
$current_page = round($n/$per_page+1);
if ($num_posts!=0)
{
?>
<center>
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td class='txt_label'>
نمایش <?php print($n_found);?> <b><?php print($n+1);?></b> از <b>
<?php
if($next==1)
{
print $n_next;
}
else
{
print $num_posts;
}
if ($n_del=="delete")
{
print "</b>";
}
else
{
print "</b> of <b>".$num_posts."</b> $n_ending";
}
?>
</td>
<td align="right">
<?php
if($n!=0)
{
$n_previous=$n-$per_page;
?>
<a href='<?php print($page);?>?n=<?php print($n_previous);?>&<?php print($string);?>'><span class="red">«</span> قبلي</a>
<?php
}
if ($current_page>5)
{
print " <a href='$page?n=0&$string'>...</a> ";
$counts = $current_page-5;
}
while ($counts < $current_page)
{
$goto_page = $counts*$per_page;
$counts++;
if ($counts==$current_page)
{
print "<a href='$page?n=$goto_page&$string'><b>$counts</b></a> ";
}
else
{
print "<a href='$page?n=$goto_page&$string'><u>$counts</u></a> ";
}
}
$counts=0;
$counts = $current_page;
while ($counts < $total_pages && ($counts-$current_page < 4))
{
$goto_page = $counts*$per_page;
$counts++;
if ($counts==$current_page)
{
print "<b>$counts</b> ";
}
else
{
print "<a href='$page?n=$goto_page&$string'><u>$counts</u></a> ";
}
}
if ($total_pages-$current_page>=5)
{
if ($n_del!="delete")
print " <a href='$page?n=".($total_pages-1)*$per_page."&$string'>...</a> ";
}
if($next==1)
{
?>
<a href='<?php print($page);?>?n=<?php print($n_next);?>&<?php print($string);?>'>بعدي <span class="red">»</span></a>
<?php
}
?>