Jump to content


This topic is now archived and is closed to further replies.


Help, I cant get to work a piece of code

Recommended Posts

guys i cant get to work a this pagination code. this source code, has not been taken from phpFreaks, but maybe someone can help me out, cause im getting really mad with this..

First, i have 3 categories in my download script.
1rst. LAW1
2nd. LAW2

and i make a diferent page for each categorie, for example law1.php and law2.php

the problem is that each page is counting the global number of pages..

for example. I have 60 downloads in each category, and i set the number of results per page to 30, but i go to law1.php and shows me 6 links, that is to say that shows me the 2 of law1 and the 2 of law 2 and the other 2 from others, instead of showing 2.

you undertand ?

the scripts must show me only 2 pages per categorie, but instead shows me 6...

in each page i have something like this :


html code
///// and here comes the php stuff


$limit = 30;
$indexlimit = 5;

if(!$_GET[page]) $_GET[page]=1;
$start = ($_GET[page]-1)*$limit;

function pagelinks($ispage=1,$getme = "order by id DESC"){
global $limit;
    $indb = mysql_numrows(mysql_query("SELECT * FROM downloads $getme"));
    $pagenumber = $indb / $limit;
    while($pagecnt <= $pagenumber)
        if($pagecnt == $ispage){echo "[ $pagecnt ] ";}
        else{echo "<a href=\"?page=$pagecnt\" target=_self>$pagecnt</a>\n ";}

$result = mysql_query("select * from downloads WHERE category = 'law1' order by id DESC limit $start,$limit");

   //display the row
echo ("$date - <a href='download.php?id=$id'>$title</a><br>");

echo"<br>Page: \n";


///////////// more html here and page ending[/code]

Please any help is much apreciated....

Share this post

Link to post
Share on other sites
$indb = mysql_numrows(mysql_query("SELECT * FROM downloads $getme"))

thats not how i do my pagination, but in this case you should do this

$indb = mysql_result(mysql_query("SELECT * FROM downloads "),0)
$pagenumber = ceil($indb / $limit);

Share this post

Link to post
Share on other sites


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.