Last line in MYSQL table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nick

    Last line in MYSQL table

    I wrote a news script to post news posts in reverse chronological
    order.

    I'd like a page to post the last 6 posts from a page, from newest to
    oldest.

    But as it is, I don't know how to find the number of the last row in
    the table. So I have to count down from 100, skipping blank entries
    along the way.

    Is there a simple way to find what how many rows are in a mysql table?
  • William Holroyd

    #2
    Re: Last line in MYSQL table


    "Nick" <fresh27@fresh2 7.net> wrote in message
    news:865bbc55.0 405082107.44492 2aa@posting.goo gle.com...[color=blue]
    > I wrote a news script to post news posts in reverse chronological
    > order.
    >
    > I'd like a page to post the last 6 posts from a page, from newest to
    > oldest.
    >
    > But as it is, I don't know how to find the number of the last row in
    > the table. So I have to count down from 100, skipping blank entries
    > along the way.
    >
    > Is there a simple way to find what how many rows are in a mysql table?[/color]

    Flip your table around by adding "ORDER BY date_added DESC" to make the last
    entries come to the 'front' and adding "LIMIT 6" to your query which will
    give you the first 6 entries.

    "SELECT * FROM news_articles (WHERE <if any where statements are needed>)
    ORDER BY date_added DESC LIMIT 6"

    I think that is what your are trying to do.

    William


    Comment

    Working...