jerastraub Posted February 15, 2008 Share Posted February 15, 2008 I have a pagination script, i just need a tip on how to add "Displaying 1 to 9 (of 14 products)" any help would be great! Quote Link to comment https://forums.phpfreaks.com/topic/91215-pagination/ Share on other sites More sharing options...
cyrixware Posted February 15, 2008 Share Posted February 15, 2008 I see... so every page your going to display 9 rows only? <? include("connDB.php"); $Limit = 9; //Number of results per page $SearchString=$_POST["lotId"]; // Get the search tearm If($SearchString == "") $SearchString=$_GET["SearchString"]; // Get the search tearm $page=$_GET["page"]; //Get the page number to show If($page == "") $page=1; //If no page number is set, the default page is 1 //Get the number of results $SearchResult=mysql_query("SELECT * FROM phase ORDER BY lotNum") or die(mysql_error()); $NumberOfResults=mysql_num_rows($SearchResult); //Get the number of pages $NumberOfPages=ceil($NumberOfResults/$Limit); $SearchResult=mysql_query("SELECT * FROM phase ORDER BY lotNum LIMIT " . ($page-1)*$Limit . ",$Limit") or die(mysql_error()); While($row = mysql_fetch_object($SearchResult)) { $x = $x + 1; if ($x % 2 != 0) { $x = $x + 1; Echo $row->lotBlock . "<BR>"; Echo $row->lotNum . "<BR>"; } } $Nav=""; If($page > 1) { $Nav .= "<A HREF=\"phase2.php?page=" . ($page-1) . "\"><<</A>"; }else{ //$Nav .= " << "; } For($i = 1 ; $i <= $NumberOfPages ; $i++) { If($i == $page) { $Nav .= "<B>$i</B>"; }Else{ $Nav .= "<A HREF=\"phase2.php?page=" . $i ."\"> $i </A>"; } } If($page < $NumberOfPages) { $Nav .= "<A HREF=\"phase2.php?page=" . ($page+1) . "\">>></A>"; }else{ //$Nav .= " >> "; } Echo "" . $Nav; ?> Quote Link to comment https://forums.phpfreaks.com/topic/91215-pagination/#findComment-467500 Share on other sites More sharing options...
jerastraub Posted February 15, 2008 Author Share Posted February 15, 2008 Hello, This is doing the pagination part ie.(<< 1 2) or (1 2 >>). I need it to also do "Displaying 1 to 9 (of 14 products)". Quote Link to comment https://forums.phpfreaks.com/topic/91215-pagination/#findComment-467591 Share on other sites More sharing options...
jerastraub Posted February 15, 2008 Author Share Posted February 15, 2008 much like the following: Items 11-20 of 100 displayed. 11 12 13 14 15 16 17 18 19 20 first prev [1-10][11-20][21-30][31-40][41-50][51-60][61-70][71-80][81-90][91-100] next last back to home page Quote Link to comment https://forums.phpfreaks.com/topic/91215-pagination/#findComment-467672 Share on other sites More sharing options...
jerastraub Posted February 16, 2008 Author Share Posted February 16, 2008 "bump" Quote Link to comment https://forums.phpfreaks.com/topic/91215-pagination/#findComment-468129 Share on other sites More sharing options...
jerastraub Posted February 20, 2008 Author Share Posted February 20, 2008 Anyone that can help me with this? Quote Link to comment https://forums.phpfreaks.com/topic/91215-pagination/#findComment-471436 Share on other sites More sharing options...
sasa Posted February 20, 2008 Share Posted February 20, 2008 add echo 'Displaying ',$page*$Limit-$Limit+1,' to ',($page*$Limit)<$NumberOfResults?($page*$Limit):$NumberOfResults, ' (of ',$NumberOfResults,' products)'; to cyrixware's code Quote Link to comment https://forums.phpfreaks.com/topic/91215-pagination/#findComment-471498 Share on other sites More sharing options...
jerastraub Posted February 21, 2008 Author Share Posted February 21, 2008 This worked great, but i can't find the topic solved button Quote Link to comment https://forums.phpfreaks.com/topic/91215-pagination/#findComment-472529 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.