Click to See Complete Forum and Search --> : ORDER BY date query?


chrisb
04-04-2005, 04:39 AM
Hi,

I'm trying to select data from my database to output on a php page:

SQL = "SELECT * FROM `tablename` ORDER BY date";

Now this works fine, but what I want is instead of selecting it by date, I want it to look in a variable named $dateone for all records and order it by the date there.

Now what I do not understand is how the code recognises the date? Say I have one record date as 11th January and another 12th March, surely it would not recognise to put 11th January first? Would it recognise 11/1/05 and 12/03/05 if I inputted that into my variable or not?

Hope that makes sense!

Thanks

Chris

solomon
04-04-2005, 05:17 AM
Hi

Although people here will probably be able to help, it's a php forum; and although you're scripting with php, the technology you're asking about is MySQL. You might want to try the MySQL forums here (http://forums.mysql.com) if you need more database techie advice

ffurnai
04-04-2005, 08:15 AM
Couldn't you enter your "manual" date info in the same format as the timestamp(14) "type" of field? Then you could ORDER by date and have it. The date would look like this (20050404061405) but then you could format it to display how you want.

This might be a really weird way to do it but the ordering by date would be a snap.

Ian