Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: pagination

  1. #1
    New Coder
    Join Date
    Jun 2005
    Posts
    41
    Thanks
    3
    Thanked 0 Times in 0 Posts

    pagination

    Could someone please help me on a little problem iam having...


    I have a script ye that i need pagination on..ive tryed loads of pagination scripts but still no luk...

    iam trying to select links from db thats in a category.....

    here is what ive tred up 2 now.

    $cat= $_GET[cats];

    $query="SELECT * FROM thelinks WHERE catid=$cat";

    more paginination code here etc............

    $query="SELECT * FROM thelinks WHERE catid=$cat LIMIT $start,$limit";


    echo out the pages etc........

    but i havnt a clue how to pagaination from a category..like this lol.......


    (category)tutorials >> display the links but with pagination

    (category)Templates >> display the links but with pagination

    my link shud be like this: ?catid=$cats&page=$i

    its giving me a head ake because in the mysql i need to use a category aswell....


    please help its been bugging me for days..........
    Last edited by ab123; 11-20-2006 at 02:23 AM.

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Post all your code so far and the database sructure for thelinks

  • #3
    New Coder
    Join Date
    Jun 2005
    Posts
    41
    Thanks
    3
    Thanked 0 Times in 0 Posts
    <?php
    mysql_connect("localhost","user","pass");
    mysql_select_db("db");

    $num = $_GET['num'];
    if(empty($num)){
    $num = 1;
    }

    $cato = $_GET['catid'];
    if(empty($cato)){
    $cato = 1;
    }

    $self = $_SERVER['PHP_SELF'];

    $limit = 4;

    $start = ($num-1)*$limit;
    $start = round($start,0);

    $query = "SELECT * FROM thelinks WHERE catid='$cato' LIMIT $start, $limit";
    $result = mysql_query($query);

    while($res2=@mysql_fetch_array($result)) {

    $idlinks = $res2[linkid];
    $sitename = $res2[linkname];

    echo "<a href=\"fullinfo.php?catid=$cato&linkid=$idlinks\">";

    echo $sitename;

    echo "</a><br><br>";
    }

    $totalpages = mysql_num_rows(mysql_query("SELECT * FROM thelinks WHERE catid='$cato'"));


    $totalpages = $totalpages / $limit;
    $totalpages = round($totalpages,0);
    $c = 0;
    echo "<br>";

    while($c<$totalpages){
    $page = $c + 1;
    if($_GET['num']==$page){
    echo "[$page] ";
    }else{//else
    echo "<a href=$self?catid=$cato&num=$page>[$page] </a>";
    }
    $c = $c+1;
    }
    echo "<br>".$totalpages." Pages in total.";
    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •