Jump to content

NalaTheFurious

New Members
  • Posts

    6
  • Joined

  • Last visited

NalaTheFurious's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have a table in my database called "blogs" which contains all of the relevant information for each blog entry. In addition to that I have the url structure on my website set up like the following: http//website.com/page/1 http://website.com/page2 http://website.com/page3 Where each page will contain 10 results from that table "blogs" (no problem up to this point). I can easily display 10 results from my database onto each page, however this is based off the incrementing"id" field in the table "blogs" which shows all of the entries in the order they are put into the database. Here is the code that I am using thus far: $blogCount = BlogCount(); $page = (isset($_GET["page"]) && is_numeric($_GET["page"])) ? (int) htmlentities($_GET["page"]) : 1; $page = ($page < 1) ? 1 : $page; $pageCount = ceil($blogCount / 10); $page = ($page > $pageCount) ? $pageCount : $page; $stop = $page * 10; $start = $stop - 9; $blogs = BlogRange($start, $stop); In the above code the function BlogRange() will select the blogs based off the "id" range which is calcualated based off the page number, which uses this mysqli prepared statement: SELECT * FROM blog WHERE id BETWEEN ? AND ? -- Now, my question is.. taking all of this into consideration.. how would I select the newer entries? I want the first page of my blog to show the newest entries on the first page instead of what was submitted into the database first.
  2. 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. 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.
  3. 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.
  4. I couldn't quite find what I was looking for when I searched for this. 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.
  5. 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.
  6. 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.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.