help with php pagination

Hi, i want to have these options:

FirstPage | PreviousPage | 1 2 3 4 5 6 7 8 9 10 | NextPage | Last Page

and show 30 iteams per Page.

what my current coding is doing ryt now:

if i put down 30 iteams per page and it also shows me 30 Pages Links in pagination and effecting my layout… but i only want 10 pages links to be displayed in navigation per page… for example if users are on page 10 show: First Page | Prev Page | 10 11 12 13 14 15 16 17 18 19 20 | Next Page | Last Page

My Script isnt showing me options of FirstPage & LastPage in Pagination.

please help me out.

Index.php
[php]<?php
include “includes/conn_db_connection.php”;
include “includes/function_lib.php”;

$catname=str_replace(’_’, ’ ‘,$_REQUEST[‘catname’]);
$data= mysql_fetch_object($s->getDataWithCondition(‘tbl_category’, "category_name=’$catname’"));
$catid=$data->category_id;

$catid=$_REQUEST[‘cat’];
?>

All Latest <?=$catname?>
<?php include "includes/header.php";?>
<?php include "includes/left_category.php"; ?> <?php include "includes/left_myaccount.php"; ?> <?php include "includes/left_ads.php"?> <?php include "includes/left_facebook.php"; ?>
<?php echo strtoupper($catname); ?> ALL ALBUMS
<?php include "includes/middle_top.php"?>
<?php include("includes/paging.php"); $ct=0; $search2=" select cat.category_id,cat.category_name,alb.artist_id as all_artist_id,alb.album_id,alb.album_name,alb.cover_image_small,alb.album_tracks, alb.release_date, art.artist_id, art.artist_name from tbl_category as cat, tbl_album as alb, tbl_artist as art where cat.category_id=alb.category_id and alb.album_status = 'active' and art.artist_id IN (alb.artist_id) and cat.category_name='$catname' ORDER BY alb.album_id DESC "; //paging code start $itemPerPage=30; $records = $search2; $qry=getPagingQuery($records, $itemPerPage); $search = $qry; $search1 = mysql_query($qry); $pageLink=getPagingLink($records,$itemPerPage,$qry,''); $noUser = mysql_num_rows($search1); //paging end here $cqry=mysql_query($search) or die(mysql_error()); $num=mysql_num_rows($cqry); if($num>0) { while( $cat_data=mysql_fetch_object($cqry) ) {
			  if(empty($cat_data->release_date)){ $rldate='unknown'; } else{ $rldate= date('Y', strtotime($cat_data->release_date)); }
		 ?>
				<div class="various" >
                <div class="cd_cover">
                  <div class="imag1"><a href="<?php echo $root; ?>/<?php echo strtolower(str_replace(' ', '_',$catname)); ?>/album-<?php echo $cat_data->album_id;?>/<?php echo strtolower(str_replace(' ', '_',$cat_data->album_name));?>-<?php echo strtolower(str_replace(' ', '_',$cat_data->artist_name));?>/"><img src="<?php echo $root; ?>/<?php echo $cat_data->cover_image_small; ?>" height="76" width="76" /></a></div>
                </div>
                <div class="tetc">
                  <div class="ultimet"><a href="<?php echo $root; ?>/artist/<?php echo strtolower(str_replace(' ', '_',$cat_data->artist_name)); ?>-<?php echo $cat_data->artist_id; ?>/"><?php echo $cat_data->artist_name; ?></a></div>
                  <div class="ultimet"><a href="<?php echo $root; ?>/<?php echo strtolower(str_replace(' ', '_',$catname)); ?>/album-<?php echo $cat_data->album_id;?>/<?php echo strtolower(str_replace(' ', '_',$cat_data->album_name));?>-<?php echo strtolower(str_replace(' ', '_',$cat_data->artist_name));?>/"><?php echo $cat_data->album_name; ?></a></div>
                  <div class="ultimet"><?php echo $cat_data->album_tracks; ?> tracks</div>
                  <div class="ultimet"><?php $s->get_litners($cat_data->album_id); ?></div>
                  <div class="ultimet"><?php echo $rldate; ?>- <?php echo $cat_data->category_name; ?></div>
                </div>
              </div>
       <?php $ct++; } } if($num==0) { ?>  
       <div style=" font-size:20px;color:#FF0000; height:35px;"> No Record Found in database </div>
       <?php } ?>
    </div>
  </div>
  <div class="main" >
  <?php if($pageLink[1]) {?>
  
    <strong><?php echo $pageLink[0]; ?></strong>
        <div class="mi">
          <ul>
          <?php echo  $pageLink[1]; ?>
          </ul>
        </div>
        <div class="right_arrow"> <strong><?php echo $pageLink[2]; ?></strong>&nbsp;<img src="<?php echo $root;?>/images/righ.png" /> </div>
      </div>
      <div class="main_breadcum_right"></div>
    </div>
    <?php } ?>
  </div>
  <div class="main" style="padding-top:22px; padding-bottom:55px; text-align:center;"> <?php include "includes/middle_bottom.php"?> </div>
</div>
<!-- Right Part end HEre -->

    <!-- Right Part Start  Here -->  
 
  <div class="righta">
      <!-- right search strart  -->
      <?php include "includes/right_search.php"; ?>
      <!-- right search End  -->
      
      <!-- Right Top 10 Songs start -->
      <?php include "includes/right_topsongs.php"; ?>
      <!-- Right Top 10 Songs End -->
      
      <!-- Right Sponsers start -->
      <?php include "includes/right_sponsers.php"; ?>
      <!-- Right Sponsers End -->
  </div>
  <!-- Right Part End  Here -->   
<!-- footer Start   -->
<?php include "includes/footer.php"; ?>
 <!-- footer End   -->
[/php]

Paging.php

[php]

<?php global $offset; function getPagingQuery($sql, $itemPerPage ) { if (isset($_GET['page']) && (int)$_GET['page'] > 0) { $page = (int)$_GET['page']; } else { $page = 1; } $offset = ($page - 1) * $itemPerPage; return $sql . " LIMIT $offset, $itemPerPage"; } function getPagingLink($sql, $itemPerPage , $strGet ='',$search_key) { global $db; $result = mysql_query($sql); $pagingLink = ''; $totalResults =mysql_num_rows($result); $totalPages = ceil($totalResults / $itemPerPage); $numLinks = $itemPerPage; if ($totalPages > 1) { include "includes/conn_db_connection.php"; $ID = $_REQUEST['catname']; $self = $root."/".$ID."-all-albums"; $page_name=basename($_SERVER['PHP_SELF']); if(isset($_REQUEST['profile_id'])!="") { $self=$HTTP_PATH.$page_name."?profile_id=".$_REQUEST['profile_id']; } if (isset($_GET['page']) && (int)$_GET['page'] > 0) { $pageNumber = (int)$_GET['page']; } else { $pageNumber = 1; } if ($pageNumber > 1) { $page = $pageNumber - 1; if ($page > 1) { $prev = "Prev"; } else { $prev = "Prev"; } $first = "First"; } $first = "First"; // nor 'first page' link if ($pageNumber < $totalPages) { $page = $pageNumber + 1; $next = "Next"; $last = "Last"; } else { $next = "Next "; $last = "Last"; } $start = $pageNumber - ($pageNumber % $numLinks) + 1; $end = $start + $numLinks - 1; $end = min($totalPages, $end); $pagingLink = array(); for($page = $start; $page <= $end; $page++) { if ($page == $pageNumber) { $pagingLink[] = "
  • $page
  • "; // no need to create a link to current page } else { if ($page ==1) { $pagingLink[] = "
  • $page
  • "; } else { $pagingLink[] = "
  • $page
  • "; } } } $pagingLink = implode(' ', $pagingLink); //$pagingLink = $first .'   '. $pagingLink .'   '. $last; } return array($prev, $pagingLink, $next); } ?>[/php]

    CSS i want it to use for Pagination

    [code] ul.pagination li.details{
    color:#FFA200;
    }

    ul.pagination li a
    {
    	color:#333333;
    	text-shadow:0px 1px #F6F6F6;
    	padding:6px 9px 6px 9px;
    	border:solid 1px #B6B6B6;
    	box-shadow:0px 1px #EFEFEF;
    	-moz-box-shadow:0px 1px #EFEFEF;
    	-webkit-box-shadow:0px 1px #EFEFEF;
    	background:#E6E6E6;
    	background:-moz-linear-gradient(top,#FFFFFF 1px,#F3F3F3 1px,#E6E6E6);
    	background:-webkit-gradient(linear,0 0,0 100%,color-stop(0.02,#FFFFFF),color-stop(0.02,#F3F3F3),color-stop(1,#E6E6E6));
    }
    
    ul.pagination li
    {
    	padding-bottom:1px;
    }
    
    ul.pagination li a:hover,
    ul.pagination li a.current
    {	
    	color:#FFFFFF;
    	box-shadow:0px 1px #E7E7E7;
    	-moz-box-shadow:0px 1px #E7E7E7;
    	-webkit-box-shadow:0px 1px #E7E7E7;       
    }
      
    ul.pagination li a:hover,
    ul.pagination li a.current
    {
    	color:#893A00;
    	text-shadow:0px 1px #FFEF42;
    	border-color:#FFA200;
    	background:#FFC800;
    	background:-moz-linear-gradient(top,#FFFFFF 1px,#FFEA01 1px,#FFC800);
    	background:-webkit-gradient(linear,0 0,0 100%,color-stop(0.02,#FFFFFF),color-stop(0.02,#FFEA01),color-stop(1,#FFC800));
    }         [/code]
    

    thANKS in advance

    Sponsor our Newsletter | Privacy Policy | Terms of Service