$num=15; // - if(isset($_REQUEST['page'])){$page=intval($_REQUEST['page']);}else{$page=1;} $posts=mysql_result(mysql_query("SELECT COUNT(*) FROM table"),0); if(!$posts){ echo '<div class="z1"> </div>'; }else{ if($page<1){$page=1;} $total=intval(($posts-1)/$num)+1; if($page>$total){$page=$total;}elseif($page<1){$page=1;} $start=$page*$num-$num; $res=mysql_query("SELECT * FROM table ORDER BY id DESC LIMIT ".$start.", ".$num); while($m=mysql_fetch_assoc($res)){ /* */ } page($posts,$_SERVER['PHP_SELF'].'? ',$page,$total,' , , '); } ############################### : ############################### function page($posts,$hvost,$page,$total,$who){ echo '<br/><div class="z2"> <div style="text-align: center;"> '.$who.': '.$posts.'</div>'; ####### if($page!=1){ $page1='<a href="'.$hvost.'&amp;page='.($page-1).'">&lt;&lt;.</a> '; if($page!=$total){$page1.='|| ';} }else{$page1='';} if($page<$total){ $page2='<a href="'.$hvost.'&amp;page='.($page+1).'">.&gt;&gt;</a>'; }else{$page2='';} if($page1 or $page2){echo $page1.$page2.'<br/>';} ####### $pp=$p2l=$p1l=$p1r=$p2r=$np=''; if($page<$total){ $p1r='<a href="'.$hvost.'&amp;page='.($page+1).'">'.($page+1).'</a>'; if($page+1!=$total and $total-4<$page){$p1r.=',';} } if($page+4<$total){ $p1r.=',<a href="'.$hvost.'&amp;page='.($page+2).'">'.($page+2).'</a>'; } if($page-3>0){ $pp='<a href="'.$hvost.'&amp;page=1">1</a>'; if($page-4>0){ $pp.=',<a href="'.$hvost.'&amp;page=2">2</a>'; } if($page-5>0){ $pp.=',<a href="'.$hvost.'&amp;page=3">3</a>'; } if($page-6>0 and $page<8){ $pp.=',<a href="'.$hvost.'&amp;page=4">4</a>'; } if($page>7){$pp.='...';}else{$pp.=',';} } if($page+2<$total){ $np='<a href="'.$hvost.'&amp;page='.$total.'">'.$total.'</a>'; } if($page-2>0){ $p2l='<a href="'.$hvost.'&amp;page='.($page-2).'">'.($page-2).'</a>,'; } if($page-1>0){ $p1l='<a href="'.$hvost.'&amp;page='.($page-1).'">'.($page-1).'</a>,'; } if($total-3>$page){ if($page+3==$total-3){ $p2r=',<a href="'.$hvost.'&amp;page='.($total-3).'">'.($total-3).'</a>'; } if($page+2<$total-4){$p2r.='...';}else{$p2r.=',';} $p2r.='<a href="'.$hvost.'&amp;page='.($total-2).'">'.($total-2).'</a>,<a href="'.$hvost.'&amp;page='.($total-1).'">'.($total-1).'</a>,'; }elseif($page+1<$total){ $p2r='<a href="'.$hvost.'&amp;page='.($page+2).'">'.($page+2).'</a>'; if($page+2<$total){$p2r.=',';} } --------------------------------------------------- if($total!=1){ echo $pp.$p2l.$p1l.' <b>'.$page.'</b> '.$p1r.$p2r.$np; } if($total>10){ echo '<form action="'.$hvost.'&amp;gorand='.rand(1,999).'" method="post"> <input type="text" name="page" size="3" maxlength="3" value="'.$page.'" /><br/> <input class="s" type="submit" value="Go!" /> </form>'; } echo '</div>'; } ----------------------------------------------------- - <?php // $p = (isset($_
далее
перейти
в начало
В библиотеку

на главную



..
(c) xika.ru