Blink Posted March 16, 2012 Report Share Posted March 16, 2012 (edited) Sveiki, vajag nelielu palīdzību , jeb kurš varētu pielabot šo kōdu... Pieņemsim ka kopā ir 210 ID Tātad - viņš parāda visus ID kas ir , bet man vajag lai viņš parāda šādi 1,2,3,4,5,6,7,8,9,10 ..... 210 Un ja uzspiež uz 10, parāda : 10,11,12,13,14,15,16,17,18,19,20 .... 210 Ceru, ka pateicu saprotami... <? include_once("config.php"); $perpage=1; $_LIMIT=(!empty($_GET['page']) && $_GET['page']>1)?($_GET['page']*$perpage)-$perpage:0; $_LIMIT.=", ".$perpage; $sql="SELECT SQL_CALC_FOUND_ROWS `id` FROM `users` GROUP BY `id` DESC LIMIT ".$_LIMIT; $res=mysql_query($sql) or die(mysql_error()); $count=mysql_fetch_object(mysql_query("SELECT FOUND_ROWS() as c")); $pages=splittopages($count->c,$perpage); if($_GET['id']<2){ $_GET['id']=1; } $now=array_search($_GET['id'],$pages); $prev=$now-1; $next=$now+1; foreach($pages as $value){ $active=$_GET['id']==$value?'':''; echo ' <a id="pages" href="?id='.$value.'"'.$active.'>'.$value.'</a>'; } ?> Te ir funkcija <? function splittopages($count,$perpage){ $pagescount=ceil($count/$perpage); $pages=array(); if($pagescount<2){ return $pages; } for($i=1;$i<=$pagescount;$i++){ $pages[]=$i; } return $pages; } ?> Edited March 16, 2012 by Blink Quote Link to comment Share on other sites More sharing options...
Blink Posted March 17, 2012 Author Report Share Posted March 17, 2012 Sorry, par DP , var taisīt ciet, sataisiju pats . :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.