Comment by wfareed on December 28, 2010 at 11:33 pm
@phpacademy also you can bold the $i and remove the anchor tag to make things clear, thanks for the great tutorial.
Comment by wfareed on December 29, 2010 at 12:26 am
@phpacademy Thanks for the great tutorial but i have a common sense modification which is else echo $i with no anchor tags because u r already on that page.
Comment by wfareed on December 29, 2010 at 12:54 am
Thanks for your efforts
Comment by JmanJam321 on December 29, 2010 at 1:09 am
@neomg3 Would you mind explaining how you were able to combine the pagination with the search engine? It would be much appreciated! Thanks
Comment by zauii89 on December 29, 2010 at 1:53 am
This is really helpful ,
Comment by peachiness2 on December 29, 2010 at 2:33 am
You are AWESOME!!!!!!!!!!!!!
Comment by CoolEditz on December 29, 2010 at 3:24 am
I’m doing a ranking system with over 40,000 accounts. Obviously with this method, I’ll have TONS of links. I’m currently showing 10 accounts per page with detailed information on each. How would I limit the pagination to only show 10 pages ahead or before the current page?
Comment by michaelcorelone on December 29, 2010 at 3:49 am
In this materialistic world no body gives anything free of cost.
Even saints have their agenda.
You are above saint.
Can you guide me where and how to save 30 pdf’s and when the customer has done the payment one by one everyday through Email, these saved PDF’S should reach his mail box through email..
Guide me..
Thanks
Comment by NickACote on December 29, 2010 at 4:02 am
Awesome PHP Teacher! I like how you don’t just write down the code… but you explain it as we go! EXCELLENT Tutorial~~
Comment by TheSchaef47 on December 29, 2010 at 4:35 am
One mild correction, the first else loop is
$x=0, $x<=$per_page * 3, $x=$x + $per_page
Comment by TheSchaef47 on December 29, 2010 at 5:06 am
Then a second loop with:
$y=($max_pages-4) * $per_page, $y<$record_count, $y=y + $per_page
for the last few pages.
The else code would use the following loops:
$x=0, $x=$per_page * 3, $x = $x + $per_page
for the first three pages,
$y=($start / $per_page)-1, $y <= ($start/$per_page)+1, $y = $y + $per_page
for the middle section, and
$z=($max_pages-3) * $per_page, $z<$record_count, $z=z + $per_page
for the last three pages
echo some dots in between each loop.
This is very rough, and untested.
Comment by TheSchaef47 on December 29, 2010 at 5:10 am
Actually, with some clever coding, we don’t need switch/case, just a clever if/else. So under the else { … }
if ($start / $per_page < 4 || $start / $per_page < $max_pages-4) {
code
} else {
other code
}
This treats the first three and last three pages the same, and then anything in between differently.
The display code would be much the same as the original, but you would have $x=0, $x / $per_page <= 4, $x = $x + $per_page
for your first loop
Comment by TheSchaef47 on December 29, 2010 at 5:58 am
I am going to attempt a broad answer to the many-pages question posted repeatedly here. First you need a threshold above which you will … the page numbers, let’s say 8. So since we already have a value $max_pages to know our number of pages, then say:
if ($max_pages < 9) {
the above code for pagination
} else {
code for … pagination
}
Since you want different results for different page locations, you will probably want to use a switch command with different cases depending on location.
Comment by ninjazhai30 on December 29, 2010 at 6:10 am
hey men, thank you so much for sharing this, big help for a beginner like me!!! You’re a very good PHP teacher
Comment by sarmenhb on December 29, 2010 at 7:04 am
its page – ination not pag – ination
Comment by Hitman73094 on December 29, 2010 at 7:53 am
Can any one who knows how to combine this with the search engine send me the code or send me a link? It would be much appreciated.
Comment by nykolae on December 29, 2010 at 8:47 am
@daner1986 start because you need a variable to count with records from db to show on the current page, if start=0 than the first records will be displayed if start=5 it will display from the 5th record
Comment by nykolae on December 29, 2010 at 8:56 am
Hi all, i implemented this tutorial into my website, i have joined the tutorial with search engine and i have some errors.When i search something the $record_count wont record all my records just untill $per_page so the if conditions from the buttons: next and page numbers doesn’t work anymore, because all the time the $record_count is equal with $per_page ,only on the last page $record_count is smaler than $per_page. Dis anyone had this problem? How did you solved it? Thank you
Comment by danielcreations on December 29, 2010 at 9:01 am
Thanks but…. There are alot of numbers can’t just be easy as just put like:
[1] 2 3 4 5 … 82
PLEASE!!!!
Comment by jjppmm29 on December 29, 2010 at 10:00 am
these are awsome from these tutorials i have been able to make a whole website from one php document it rocks but i must say that you can just take a deviation of the pages and increment that
Comment by noueim on December 29, 2010 at 10:59 am
thank you, very good video
Comment by phpacademyfan on December 29, 2010 at 11:10 am
love youre tutorials! after this one i actually created an youtube-account (don’t really want one, but i really want the subscription)…
think i’m gonna implement this to my “news-page”.. but before i get started… what happens when there are a couple of hounderd pages??? Is there a way to make the pagenubers to display something like this: “Prev 1 2 3 4 5 ….. 114 115 Next” when on page 3 and: “Prev .. 2 3 4 5 6 ….. 114 115 Next” when on page 3 and so on?
Thanks again // P
Comment by daner1986 on December 29, 2010 at 11:27 am
Thanks for the tutorial.
I’m Italian.
I do not understand why $start = $ _GET ['start'];
is indefinite.
I had to use the error_reporting ();
Comment by MPTutor1 on December 29, 2010 at 11:38 am
good tutorial for learning PHP…..
Comment by nerfmarius on December 29, 2010 at 11:52 am
You can add
if ($start<0)
header (‘Location: index.php’);
so u’ll avoid those mysql errors when refreshing after the change of $per_page var or if user would try to change ?start to -1 or smt.. so its more dummy friendly
About this blog
This blog is dedicated to showcasing great web design as well as providing advice and tips to any aspiring web designers out there. Hopefully these articles will aid you in your design and development.
25 comments
Comment by wfareed on December 28, 2010 at 11:33 pm
@phpacademy also you can bold the $i and remove the anchor tag to make things clear, thanks for the great tutorial.
Comment by wfareed on December 29, 2010 at 12:26 am
@phpacademy Thanks for the great tutorial but i have a common sense modification which is else echo $i with no anchor tags because u r already on that page.
Comment by wfareed on December 29, 2010 at 12:54 am
Thanks for your efforts
Comment by JmanJam321 on December 29, 2010 at 1:09 am
@neomg3 Would you mind explaining how you were able to combine the pagination with the search engine? It would be much appreciated! Thanks
Comment by zauii89 on December 29, 2010 at 1:53 am
This is really helpful ,
Comment by peachiness2 on December 29, 2010 at 2:33 am
You are AWESOME!!!!!!!!!!!!!
Comment by CoolEditz on December 29, 2010 at 3:24 am
I’m doing a ranking system with over 40,000 accounts. Obviously with this method, I’ll have TONS of links. I’m currently showing 10 accounts per page with detailed information on each. How would I limit the pagination to only show 10 pages ahead or before the current page?
Comment by michaelcorelone on December 29, 2010 at 3:49 am
In this materialistic world no body gives anything free of cost.
Even saints have their agenda.
You are above saint.
Can you guide me where and how to save 30 pdf’s and when the customer has done the payment one by one everyday through Email, these saved PDF’S should reach his mail box through email..
Guide me..
Thanks
Comment by NickACote on December 29, 2010 at 4:02 am
Awesome PHP Teacher! I like how you don’t just write down the code… but you explain it as we go! EXCELLENT Tutorial~~
Comment by TheSchaef47 on December 29, 2010 at 4:35 am
One mild correction, the first else loop is
$x=0, $x<=$per_page * 3, $x=$x + $per_page
Comment by TheSchaef47 on December 29, 2010 at 5:06 am
Then a second loop with:
$y=($max_pages-4) * $per_page, $y<$record_count, $y=y + $per_page
for the last few pages.
The else code would use the following loops:
$x=0, $x=$per_page * 3, $x = $x + $per_page
for the first three pages,
$y=($start / $per_page)-1, $y <= ($start/$per_page)+1, $y = $y + $per_page
for the middle section, and
$z=($max_pages-3) * $per_page, $z<$record_count, $z=z + $per_page
for the last three pages
echo some dots in between each loop.
This is very rough, and untested.
Comment by TheSchaef47 on December 29, 2010 at 5:10 am
Actually, with some clever coding, we don’t need switch/case, just a clever if/else. So under the else { … }
if ($start / $per_page < 4 || $start / $per_page < $max_pages-4) {
code
} else {
other code
}
This treats the first three and last three pages the same, and then anything in between differently.
The display code would be much the same as the original, but you would have $x=0, $x / $per_page <= 4, $x = $x + $per_page
for your first loop
Comment by TheSchaef47 on December 29, 2010 at 5:58 am
I am going to attempt a broad answer to the many-pages question posted repeatedly here. First you need a threshold above which you will … the page numbers, let’s say 8. So since we already have a value $max_pages to know our number of pages, then say:
if ($max_pages < 9) {
the above code for pagination
} else {
code for … pagination
}
Since you want different results for different page locations, you will probably want to use a switch command with different cases depending on location.
Comment by ninjazhai30 on December 29, 2010 at 6:10 am
hey men, thank you so much for sharing this, big help for a beginner like me!!! You’re a very good PHP teacher
Comment by sarmenhb on December 29, 2010 at 7:04 am
its page – ination not pag – ination
Comment by Hitman73094 on December 29, 2010 at 7:53 am
Can any one who knows how to combine this with the search engine send me the code or send me a link? It would be much appreciated.
Comment by nykolae on December 29, 2010 at 8:47 am
@daner1986 start because you need a variable to count with records from db to show on the current page, if start=0 than the first records will be displayed if start=5 it will display from the 5th record
Comment by nykolae on December 29, 2010 at 8:56 am
Hi all, i implemented this tutorial into my website, i have joined the tutorial with search engine and i have some errors.When i search something the $record_count wont record all my records just untill $per_page so the if conditions from the buttons: next and page numbers doesn’t work anymore, because all the time the $record_count is equal with $per_page ,only on the last page $record_count is smaler than $per_page. Dis anyone had this problem? How did you solved it? Thank you
Comment by danielcreations on December 29, 2010 at 9:01 am
Thanks but…. There are alot of numbers can’t just be easy as just put like:
[1] 2 3 4 5 … 82
PLEASE!!!!
Comment by jjppmm29 on December 29, 2010 at 10:00 am
these are awsome from these tutorials i have been able to make a whole website from one php document it rocks but i must say that you can just take a deviation of the pages and increment that
Comment by noueim on December 29, 2010 at 10:59 am
thank you, very good video
Comment by phpacademyfan on December 29, 2010 at 11:10 am
love youre tutorials! after this one i actually created an youtube-account (don’t really want one, but i really want the subscription)…
think i’m gonna implement this to my “news-page”.. but before i get started… what happens when there are a couple of hounderd pages??? Is there a way to make the pagenubers to display something like this: “Prev 1 2 3 4 5 ….. 114 115 Next” when on page 3 and: “Prev .. 2 3 4 5 6 ….. 114 115 Next” when on page 3 and so on?
Thanks again // P
Comment by daner1986 on December 29, 2010 at 11:27 am
Thanks for the tutorial.
I’m Italian.
I do not understand why $start = $ _GET ['start'];
is indefinite.
I had to use the error_reporting ();
Comment by MPTutor1 on December 29, 2010 at 11:38 am
good tutorial for learning PHP…..
Comment by nerfmarius on December 29, 2010 at 11:52 am
You can add
if ($start<0)
header (‘Location: index.php’);
so u’ll avoid those mysql errors when refreshing after the change of $per_page var or if user would try to change ?start to -1 or smt.. so its more dummy friendly