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.
×
×
  • 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.