The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

I'm really having a hard time trying to do this... so I've decided to see if you guys here can help me out.

I have a database of tips, and I want to only display the last five tips entered into the database. I want these first five to be displayed with their text. But I want the rest of the tips to be "archived" at the bottom of the page, and only their title's showing.

I have a table named tips, and these colums:

ID
Title
Content
Author
Date

The ID is an auto-incrament. The I have a online form to add tips. Each tip requires an input of a title, content, and an author. The data is auto.

So there you have it. I have played with the mysql_insert_id() taking away five etc. But I have had no luck. I have been trying to use the while statement, with no luck so far. Could anyone please shed some light?

God Bless,

Alex

Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

first know this if you don't. The most recent records added to a DB will be the first returned IF there is no overriding ORDER BY Statement.

The first thing that pops into my mind is limits. With a limit you can limit the number of results returned. For info on limits refer to Kevin's tutorial under advanced sql.

However if you want at the bottom of the page to also include remaining tips, but without their text, then you'd need a second query to acheive that.

you should try to keep down the number of queries on a page so lets choose a different approach.

What I would do is simply use a while loop, like you said. Create a counter and while it is <= 5 display records a certain way, then once that loop has run its course start displaying them the second way.