Jump to content

Help, I cant get to work a piece of code


Rama

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
3rd. OTHERS

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 :

[code]

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

<?
include("dbconnect.php");

$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;
    $pagenumber++;
    $pagecnt=1;
    while($pagecnt <= $pagenumber)
        {
        if($pagecnt == $ispage){echo "[ $pagecnt ] ";}
        else{echo "<a href=\"?page=$pagecnt\" target=_self>$pagecnt</a>\n ";}
        $pagecnt++;
        }
}

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

while($r=mysql_fetch_array($result))
{    
  
   $id=$r["id"];
   $title=$r["title"];
   $date=$r["date"];
   $link=$r["link"];
  
   //display the row
echo ("$date - <a href='download.php?id=$id'>$title</a><br>");
}

echo"<br>Page: \n";
pagelinks($_GET[page]);

?>


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



Please any help is much apreciated....
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

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.