Rama Posted June 11, 2006 Share Posted June 11, 2006 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. LAW12nd. LAW23rd. OTHERSand i make a diferent page for each categorie, for example law1.php and law2.phpthe 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 rowecho ("$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 https://forums.phpfreaks.com/topic/11687-help-i-cant-get-to-work-a-piece-of-code/ Share on other sites More sharing options...
corillo181 Posted June 11, 2006 Share Posted June 11, 2006 $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); Link to comment https://forums.phpfreaks.com/topic/11687-help-i-cant-get-to-work-a-piece-of-code/#findComment-44183 Share on other sites More sharing options...
Rama Posted June 11, 2006 Author Share Posted June 11, 2006 THANKS... THAT WORKED..FINE...YOUR HELP WAS MUCH APRECIATED Link to comment https://forums.phpfreaks.com/topic/11687-help-i-cant-get-to-work-a-piece-of-code/#findComment-44185 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.