چرا هیچ کس جواب سوالات نمی ده گسی می تونه کمک کنه در مورد کد شمارس صفحه

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'> 
&nbsp;نمایش <?php print($n_found);?>&nbsp;<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>&nbsp;قبلي</a>&nbsp;&nbsp; 
<?php 
} 

if ($current_page>5) 
{ 
 print "&nbsp;&nbsp;<a href='$page?n=0&$string'>...</a>&nbsp;"; 
 $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>&nbsp;"; 
 } 
 else 
 { 
 print "<a href='$page?n=$goto_page&$string'><u>$counts</u></a>&nbsp;"; 
 } 
} 

$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>&nbsp;"; 
 } 
 else 
 { 
 print "<a href='$page?n=$goto_page&$string'><u>$counts</u></a>&nbsp;"; 
 } 
} 

if ($total_pages-$current_page>=5) 
{ 
 if ($n_del!="delete") 
 print "&nbsp;&nbsp;<a href='$page?n=".($total_pages-1)*$per_page."&$string'>...</a>&nbsp;"; 
} 

if($next==1) 
{ 
?> 
  &nbsp;&nbsp;<a href='<?php print($page);?>?n=<?php print($n_next);?>&<?php print($string);?>'>بعدي&nbsp;<span class="red">»</span></a> 
<?php 
} 
?>
 

ahmad_m1234

Active Member
من دقیقا کد شما متوجه نشدم اما کدی که خودم از سایتی گرفتم می تونی استفاده کنی

PHP:
if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }; 
$start_from = ($page-1) * 20; 

$query = "SELECT * FROM table order by id desc";
$query_limit = sprintf("%s LIMIT %d, %d", $query, $start_from, 20);
$rec_query = mysql_query($query_limit) or die(mysql_error());
$row_query  = mysql_fetch_assoc($rec_query);

کد:
<table width="580" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
    <td width="595" valign="top"> 
<?php

$sql = "SELECT COUNT(*) FROM table"; 
$rs_result = mysql_query($sql); 
$row = mysql_fetch_row($rs_result); 
$total_records = $row[0];
$total_pages = ceil($total_records / 20); 
for ($i=1; $i<=$total_pages; $i++) { 
            echo "<a align='center' class='nav-a2' href='page.php?page=".$i."'>".$i."</a> "; 
}; 
?></td>
      <td width="49" valign="middle"> 
<font size="2"> : صفحه</font>  </td>
</tr>
</table>
 

جدیدترین ارسال ها

بالا