468,785 Members | 1,623 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,785 developers. It's quick & easy.

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?
Jul 17 '05 #1
1 2013

"Nick" <fr*****@fresh27.net> wrote in message
news:86**************************@posting.google.c om...
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?


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
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Carlos Marangon | last post: by
3 posts views Thread by josh dismukes | last post: by
8 posts views Thread by Shawn McKenzie | last post: by
4 posts views Thread by Ike | last post: by
3 posts views Thread by cdelarte | last post: by
1 post views Thread by mosesdinakaran | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.