SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2003
    Location
    P Town
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Showing the last five items

    Ok, my brain must be running slow right now because I cannot think of an answer to what must be a basic problem.

    I have a comment system where I want to show the last five comments.

    So say I have 20 comments. I would like to display comments 15-20

    I have tried "ORDER BY id DESC LIMIT 5" but it shows the last comment at the top of the page and comment 15 at the bottom. I would like comment 15 at the top and comment 20 at the bottom.

    Any help would be awsome!
    Last edited by Zboyet; Dec 28, 2004 at 20:59.

  2. #2
    Formerly known as RockNRollPig Shpigford's Avatar
    Join Date
    Dec 2002
    Location
    Denver, CO
    Posts
    2,877
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ORDER BY id ASC LIMIT 5

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2003
    Location
    P Town
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RockNRollPig
    ORDER BY id ASC LIMIT 5
    If I do that it shows comments 1-5 and I want to show 15-20. I need to show the last five comments made from oldest to newest.

    Is there a way to do an order by asc but limit it to the last five entries?

  4. #4
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try...
    PHP Code:
    ...LIMIT 15
    Lats...

  5. #5
    SitePoint Zealot
    Join Date
    Oct 2003
    Location
    P Town
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Lats
    Try...
    PHP Code:
    ...LIMIT 15
    Worked like a charm THANKS!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •