NalaTheFurious Posted May 29, 2015 Share Posted May 29, 2015 (edited) Basically, with the project that I have going now I am using $pageNumber to indicate what page that the user is currently on. I want to display 10 articles for each page for example: $pageNumber == 1 >> $start=1; $stop=10; $pageNumber == 2 >> $start=11, $stop=20; $pageNumber == 3 >> $start=21, $stop=30; $pageNumber == 4 >> $start=31, $stop=40; etc..etc.. However, I have not the slightest idea on how to go about this. Could someone get me pointed in the right direction? There will eventually be quite a number of pages and typing all of them out manually would take a long time. Edited May 29, 2015 by NalaTheFurious Quote Link to comment https://forums.phpfreaks.com/topic/296539-need-help-figuring-out-values-that-i-need/ Share on other sites More sharing options...
Psycho Posted May 29, 2015 Share Posted May 29, 2015 (edited) Deleted my response. I'm pretty sure this is homework and the problem is super easy. At least show an attempt at what you've tried - then ask for help showing what you tried. Edited May 29, 2015 by Psycho Quote Link to comment https://forums.phpfreaks.com/topic/296539-need-help-figuring-out-values-that-i-need/#findComment-1512813 Share on other sites More sharing options...
NalaTheFurious Posted May 29, 2015 Author Share Posted May 29, 2015 Deleted my response. I'm pretty sure this is homework and the problem is super easy. At least show an attempt at what you've tried - then ask for help showing what you tried. That's kind of rude.. not everyone is trying to do homework. I'm actually trying to make my website operational while studying for other courses though. The only thing that came to mind for me was setting the values manually for each page and that was clearly not the approach to use, but I did it anyways for the first coulpe of pages to test. I have been wrapping my mind around how to do this and nothing has been coming to mind. I have a bunch of other php incoperated into my website and some of it is highly advanced.. it's just something so simple is causing me a headache. Quote Link to comment https://forums.phpfreaks.com/topic/296539-need-help-figuring-out-values-that-i-need/#findComment-1512825 Share on other sites More sharing options...
cyberRobot Posted May 29, 2015 Share Posted May 29, 2015 Perhaps you've already done this, but you could search for "php pagination" on a search engine like Google. Quote Link to comment https://forums.phpfreaks.com/topic/296539-need-help-figuring-out-values-that-i-need/#findComment-1512826 Share on other sites More sharing options...
Barand Posted May 29, 2015 Share Posted May 29, 2015 We still need to see code. We have no idea where the articles are coming from. Quote Link to comment https://forums.phpfreaks.com/topic/296539-need-help-figuring-out-values-that-i-need/#findComment-1512827 Share on other sites More sharing options...
NalaTheFurious Posted May 29, 2015 Author Share Posted May 29, 2015 Perhaps you've already done this, but you could search for "php pagination" on a search engine like Google. I couldn't quite find what I was looking for when I searched for this. We still need to see code. We have no idea where the articles are coming from. There blogs are collected like such: $blogs = BlogRange($start, $stop); BlogRange selects blogs based off id between two numbers.. $start and $stop in this case. However, to get the $start and $stop numbers correct. Reffering to my original post I am trying to set $start and $stop based off the page number the user is currently on.. example: http//website.com/page/1 which in the code is $pageNumber When the $pageNumber is 1 I need the $start value to be 1 and $stop to be 10. When the $pageNumber is 2 I need the $start value to be 11 and $stop to be 20. etc. etc. Quote Link to comment https://forums.phpfreaks.com/topic/296539-need-help-figuring-out-values-that-i-need/#findComment-1512832 Share on other sites More sharing options...
Barand Posted May 29, 2015 Share Posted May 29, 2015 And you still haven't told us where the articles are coming from. I guess you don't want help after all. Quote Link to comment https://forums.phpfreaks.com/topic/296539-need-help-figuring-out-values-that-i-need/#findComment-1512834 Share on other sites More sharing options...
NalaTheFurious Posted May 29, 2015 Author Share Posted May 29, 2015 (edited) And you still haven't told us where the articles are coming from. I guess you don't want help after all. Why are you acting so condescending? I answered your question previously.. the articles are stored in $blog from a call such as $blogs = BlogRange($start, $stop); Where the articles come from is not really the issue here.. that works just fine for me. I am just trying to figure out a way to check my $pageNumber and get the corresponding range of values to pull from the database. ------ $pageNumber = 1; $start = 1; $stop = 10; ------ ------ $pageNumber = 2; $start = 11; $stop = 20; ------ etc..etc.. That way when a person is on my website viewing page 60 $pageNumber will equal 60 and I am trying to figure out a way to calcuate the $start and $stop based off the page number. However, typing it all out manually for each page would take forever.. just trying to write a function where I can input the $pageNumber and get the range of numbers I need for my $start and $stop. Edited May 29, 2015 by NalaTheFurious Quote Link to comment https://forums.phpfreaks.com/topic/296539-need-help-figuring-out-values-that-i-need/#findComment-1512835 Share on other sites More sharing options...
Solution jcbones Posted May 29, 2015 Solution Share Posted May 29, 2015 So: $pageNumber = (int)$_GET['page']; $stop = $pageNumber * 10; $start = $stop - 9; ?? Quote Link to comment https://forums.phpfreaks.com/topic/296539-need-help-figuring-out-values-that-i-need/#findComment-1512836 Share on other sites More sharing options...
Barand Posted May 29, 2015 Share Posted May 29, 2015 Why are you acting so condescending? I answered your question previously.. the articles are stored in $blog from a call such as Because if the data comes from a database the technique used for paginating your data will be different from that used if it comes from a text or xml file. Quote Link to comment https://forums.phpfreaks.com/topic/296539-need-help-figuring-out-values-that-i-need/#findComment-1512839 Share on other sites More sharing options...
NalaTheFurious Posted May 30, 2015 Author Share Posted May 30, 2015 So: $pageNumber = (int)$_GET['page']; $stop = $pageNumber * 10; $start = $stop - 9; ?? That's exactly what I needed.. thank you. I just couldn't think of this or how to describe this to save the life of me. Because if the data comes from a database the technique used for paginating your data will be different from that used if it comes from a text or xml file. I was trying to explain though that none of that matters because I knew the answer was much simplier than what you wanted to know. Quote Link to comment https://forums.phpfreaks.com/topic/296539-need-help-figuring-out-values-that-i-need/#findComment-1512844 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.