| | |
How to use large pagination in a limited area
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
How to use large pagination in a limited area , plz see the bottom pictures , please help me ........
as an example in my page , i have more than 100 posts
no my pagination system is like this
1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
but i want to do like this , so please help me
1 2 3 4 5 6 8 9 10 11 22 23 24
non limited - http://i31.tinypic.com/ztsmf7.jpg
limited - http://i31.tinypic.com/28wp7ys.jpg
please help me ...........
as an example in my page , i have more than 100 posts
no my pagination system is like this
1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
but i want to do like this , so please help me
1 2 3 4 5 6 8 9 10 11 22 23 24
non limited - http://i31.tinypic.com/ztsmf7.jpg
limited - http://i31.tinypic.com/28wp7ys.jpg
please help me ...........
Just use your while loop to find the number of pages (as usual), then use some rules to display certain pages.
Do you want to display a maximum of 14 pages as suggested in your post? If so do you want the last 4 pages to link to the last pages?
1) If the total number of pages = 14 or less, display all page links.
2) Otherwise display the pages if the number is 10 or less OR display if the page number is greater than the total number of pages - 4.
I'm sure there are other formulae you could use.
Do you want to display a maximum of 14 pages as suggested in your post? If so do you want the last 4 pages to link to the last pages?
1) If the total number of pages = 14 or less, display all page links.
2) Otherwise display the pages if the number is 10 or less OR display if the page number is greater than the total number of pages - 4.
I'm sure there are other formulae you could use.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
Try the following code:
php Syntax (Toggle Plain Text)
<style type="text/css"> A:link {font-weight:bold; font-family:"Arial";} A:visited {font-weight:bold; font-family:"Arial";} A:active {font-weight:bold; font-family:"Arial";} A:hover {font-weight:bold; font-family:"Arial";} </style> <? $number_of_pages=100; //maximum number of pages $current_page=50; //set the current page probably with $_GET for ($i=1;$i<=$number_of_pages;$i++) { if ($i<11) { echo ($i>1)? ' - ':''; // add dash between numbers. echo '<a href="index.php?id='.$i.'">'.$i.'</a>'; } if (($i>=($current_page-1) && $i<=($current_page+1)) || $i>=($number_of_pages-2)) { echo ' - <a href="index.php?id='.$i.'">'.$i.'</a>'; } } ?>
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
PHP Syntax (Toggle Plain Text)
for($i = 1; $i <= $total_newspage; $i++) { if(($newspage) == $i) { echo "$i\n "; } else { echo "<a href=\"news.php?newspage=$i\">$i</a>\n "; } }
i am using this lines of code to generate my basic pagination , how to modify it to my needs . please .............
•
•
•
•
PHP Syntax (Toggle Plain Text)
for($i = 1; $i <= $total_newspage; $i++) { if(($newspage) == $i) { echo "$i\n "; } else { echo "<a href=\"news.php?newspage=$i\">$i</a>\n "; } }
i am using this lines of code to generate my basic pagination , how to modify it to my needs . please .............
Page 50 selected - 100 pages total
.1 2 3 4 5 48 49 50 51 52 98 99 100 Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
this is the full code i am using and it working perfect . what i want to do is , i have more than 100 pages ( '$total_newspage' ) but i want to display like this
1 2 3 4 5 6 7 8 9 10 ... 100 ALL
when i click on 10 , want to show like this
10 11 12 13 14 15 16 17 18 19 ... 100 ALL
and after 19
19 20 21 22 23 24 25 26 27 28 ... 100 ALL , and so on
now u got it what i want to do , plz help me
now u got it what i am trying to do , plz help me
1 2 3 4 5 6 7 8 9 10 ... 100 ALL
when i click on 10 , want to show like this
10 11 12 13 14 15 16 17 18 19 ... 100 ALL
and after 19
19 20 21 22 23 24 25 26 27 28 ... 100 ALL , and so on
now u got it what i want to do , plz help me
PHP Syntax (Toggle Plain Text)
<?php if(!isset($_GET['newspage'])){ $newspage = 1; } else { $newspage = $_GET['newspage']; } // Define the number of results per page $max_results = 2; // Figure out the limit for the query based $from = (($newspage * $max_results) - $max_results); $query_Record_data = "SELECT txtPostTitle, txtPostDate, txtPostContent, txtUsername FROM generic ORDER BY intPostID ASC LIMIT $from, $max_results"; $Record_data = mysql_query($query_Record_data, $mysql_Connection) or die(mysql_error()); $row_Record_data = mysql_fetch_assoc($Record_data); $totalRows_Record_data = mysql_num_rows($Record_data); // Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM generic"),0); // Figure out the total number of pages. Always round up using ceil() $total_newspage = ceil($total_results / $max_results); echo "<p style=\"clear:both;\" align=\"center\">\n"; echo $total_newspage; ?>
PHP Syntax (Toggle Plain Text)
<?php //------------------ previous link---------------------- if($newspage > 1) { $prev = ($newspage - 1); echo "<a href=\"apps.php?newspage=$prev\">‹‹ Previous</a>\n "; echo $i; } //----------Displaying pagination bar--------------- for($i = 1; $i <= $total_newspage ; $i++) { if(($newspage) == $i) { echo "$i\n "; } else { echo "<a href=\"apps.php?newspage=$i\">$i</a>\n "; } } //-------------- Build Next Link ------------------------------------------ if($newspage < $total_newspage) { $next = ($newspage + 1); echo "<a href=\"apps.php?newspage=$next\">Next ››</a>\n"; } echo "</p>\n"; ?>
now u got it what i am trying to do , plz help me
Last edited by vijaysoft1; Sep 13th, 2009 at 12:33 pm.
Try the following:
php Syntax (Toggle Plain Text)
<? $number_of_pages=100; //maximum number of pages $current_page=$_GET['newspage']; //set the current page //set above variables //don't change the below $tmp=$current_page+10; for ($i=1;$i<=$number_of_pages;$i++) { if (($i>=($current_page-1) && $i<($tmp)) || $i==$number_of_pages) { echo '<a href="index.php?newspage='.$i.'">'.$i.'</a>'; echo (($i<($tmp) && ($tmp)<=$number_of_pages) || ($i<($tmp) && $currentpage<$number_of_pages))? ' - ':''; // add dash between numbers. } } ?>
Last edited by cwarn23; Sep 15th, 2009 at 2:42 am. Reason: error
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
I use this function to paginate:
EDITED Now its better!
You can mod. it for you...
p.s. This is used for styling:
http://www.dynamicdrive.com/style/cs...nation_links/#
PHP Syntax (Toggle Plain Text)
<?php if(isset($_GET["page"])) { $page = $_GET["page"]; } else { $page = 1; } $totalPages = 1000; function paging($page, $totalPages) { $printPages = 7; //Show only X pages $i = 1; $previous_page = ($page > 1) ? $page - 1 : 1; $next_page = $page + 1; if($totalPages < $printPages) { $printPages = $totalPages; } echo '<div class="pagination" align="center"> <ul>'; if($page > 1) { echo ' <li><a href="?page=1">«« First</a></li> '; echo ' <li><a href="?page='.$previous_page.'">« Prev</a></li> '; if($totalPages > 0) { //Nothing for now, used to have a | separator here } } if($page - 3 <= 0) { $currentPage = 1; } elseif($page > 3 && $page + 3 < $totalPages) { $currentPage = $page - 3; } else { $currentPage = $totalPages - ($printPages - 1); } while($i <= $printPages) { echo '<li><a'; if($page == $currentPage) { echo ' class="currentpage" '; } echo ' href="?page='.$currentPage.'"> '.$currentPage.' </a></li> '; $currentPage++; $i++; } if($page < $totalPages) { $next = $page + 1; echo ' <li><a href="?page='.$next.'">Next »</a></li> '; echo ' <li> <a href="?page='.$totalPages.'">Last »»</a></li> '; } echo '</ul></div>'; } //Use it paging($page, $totalPages) ?>
EDITED Now its better!
You can mod. it for you...
p.s. This is used for styling:
http://www.dynamicdrive.com/style/cs...nation_links/#
Last edited by smartness; Sep 15th, 2009 at 8:02 am.
hi friend thanks for u r help and this code , it is working perfect
but i am confused while implementing , my idea , following
this is my pagination bar
---------------------------
1 2 3 4 5 6 7 8 9 .. 98 99 100
when i click on 9th page [ here my $printPages = 9 ] , i want to increment $page ( $page = $page+9) , means i want to display like this
9 10 11 12 13 14 15 16 17 ... 98 99 100
17 18 19 20 21 22 23 24 25 .. 98 99 100
and so on
please help me , i am very confused , so plz help me
but i am confused while implementing , my idea , following
this is my pagination bar
---------------------------
1 2 3 4 5 6 7 8 9 .. 98 99 100
when i click on 9th page [ here my $printPages = 9 ] , i want to increment $page ( $page = $page+9) , means i want to display like this
9 10 11 12 13 14 15 16 17 ... 98 99 100
17 18 19 20 21 22 23 24 25 .. 98 99 100
and so on
please help me , i am very confused , so plz help me
![]() |
Similar Threads
- Dragging images in limited area (JavaScript / DHTML / AJAX)
- Cyberstalking (Network Security)
- Math Functions (C++)
- com vs. exe (Assembly)
- print large pricturebox or form in vb6 (Visual Basic 4 / 5 / 6)
- Do you need AV and Firewall? (Windows NT / 2000 / XP)
- Talk Terminal Command (OS X)
- Computer freezes when i try to install windows XP (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: Help debug Random property script.
- Next Thread: Search from text box and saving to txt file
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube






