Home > Archive > PHP SQL > November 2005 > PHP and MySQL
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Colin Roosendaal 2005-10-30, 6:58 pm |
| Hello,
Can someone tell me how to do the following:
I'm looking for the PHP/MySQL query to get the last 5 added records from my
database.
For your info
DB name: news
table name: messages
I hope you can help me.
Thanks,
Colin Roosendaal
| |
| Siv Hansen 2005-10-30, 6:58 pm |
| Colin Roosendaal wrote:
> Hello,
>
> Can someone tell me how to do the following:
>
> I'm looking for the PHP/MySQL query to get the last 5 added records from my
> database.
>
> For your info
>
> DB name: news
> table name: messages
select whatever_you_want_to_find from messages limit 5;
>
> I hope you can help me.
>
> Thanks,
>
> Colin Roosendaal
>
>
| |
| scott Johnson 2005-10-30, 9:57 pm |
| Well you will probably need to add an extra field and fill it with the
date the message was added.
Then do a query.
"SELECT * FROM news ORDER BY date_added ASC LIMIT 5"
Colin Roosendaal wrote:
> Hello,
>
> Can someone tell me how to do the following:
>
> I'm looking for the PHP/MySQL query to get the last 5 added records from my
> database.
>
> For your info
>
> DB name: news
> table name: messages
>
> I hope you can help me.
>
> Thanks,
>
> Colin Roosendaal
>
>
--
Scott Johnson
http://www.seaforthsailingclub.com
| |
| George 2005-10-31, 6:58 pm |
| In article <H1f9f.15925$MN6.7857@fed1read04>, scott Johnson says...
>
>Well you will probably need to add an extra field and fill it with the
>date the message was added.
>
>Then do a query.
>
>"SELECT * FROM news ORDER BY date_added ASC LIMIT 5"
>
If the table has a primary key, such as an integer, that would have to be unique
and could just sort on that. Would save the hassle of adding an extra column if
the date information isn't needed.
George
--
Basic Newsguy -- 3 GB / month -- $39.95 / year
http://newsguy.com/overview.htm
>Colin Roosendaal wrote:
>
| |
| scott Johnson 2005-11-01, 8:01 am |
| Good idea, I had not thought about that.
George wrote:
> In article <H1f9f.15925$MN6.7857@fed1read04>, scott Johnson says...
>
>
>
> If the table has a primary key, such as an integer, that would have to be unique
> and could just sort on that. Would save the hassle of adding an extra column if
> the date information isn't needed.
>
> George
> --
> Basic Newsguy -- 3 GB / month -- $39.95 / year
> http://newsguy.com/overview.htm
>
>
>
>
>
--
Scott Johnson
http://www.seaforthsailingclub.com
|
|
|
|
|