tags:

views:

24

answers:

1

hi all,

I got some sample data in a Table Testing which consists of two fields: (there is not primary key in this sample Table)

Data | Date

Hello     |  2010-07-1 15:11:11
World   | 2010-07-1 11:01:01
Hi there  | 2010-07-02 11:36:11

I was trying to print the data out Ordered by Date DESC in this way:

Record 1: Hi there
Record 2: Hello
Record 3: World

I have no idea how to do this using either cakePHP or PHP.

Please help if you could.

+2  A: 

In plain PHP you can do this using mysql_query.

The SQL would be:

SELECT data FROM yourtable ORDER BY Date DESC

The manual for mysql_query includes an example showing how you can execute the SQL statement and iterate over the result set. If you're having problems, post your code and the specific error.

Mark Byers