help with pagination in this script

Discussion in 'PHP' started by fakestar, May 13, 2007.

  1. #1
    Hi, i need some help to change the pagination of this script.

    I want to put this digg style pagination:

    http://www.strangerstudios.com/sandbox/pagination/diggstyle.php

    My code is:

    
     <? 
    		if ($_GET['cat']){
    		  		
    				// include db
    		  		include 'include/conn.php';
    				//sql query
    				$sql = "Select * from TABLE where category = '$_GET[cat]'";
    				$result = mysql_query($sql);
    				$num_rows = mysql_num_rows($result);
    				
    				$totalpages = ceil($num_rows/30);
    				$curpage = empty($_GET['pg'])?1:$_GET['pg'];
            if($totalpages>1) {
              echo "Pages: ";
              for($loop = 1; $loop<$totalpages+1; $loop++) {
                if($loop!=$curpage) {
    ?>
        [<a href="index.php?&amp;pg=<?php echo $loop; ?>"><?php echo $loop; ?></a>]
    
    PHP:
    That echo will appear all results, i mean if it's 1276 pages it will from [1] [2] till [1276]

    And i just want like previous| [1][2][3] ... [1274][1275][1276]| next

    Any person with good skills in php could help me please?

    Thanks in advance.
     
    fakestar, May 13, 2007 IP
  2. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Any particular reason you're not using the class provided on that website?
     
    CodyRo, May 13, 2007 IP
  3. fakestar

    fakestar Peon

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0