Jump to content
php.lv forumi

PHP pages


Blink

Recommended Posts

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 by Blink
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...