|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
order by date (not UNIX timestamp) php/mysql
Hi,
I've built a flash mx site which uses php to pull data from a mysql db and outputs xml to flash. One of the sections of the site is an up-and-coming events section (client is a DJ) and currently php outputs the xml based on a unique id but this is appearing to be unsuitable. What I;d like is to for her to add in a date for the event, and then have php query the db and order it so that the next event is first and so on, but I'm a little unsure of how to do it. How should I format the date ?? It would be easy if there was only one variable (day) but there's day, month and year! How can I query the db 3 times ???? Any insight really welcome. Thanks, Jon |
|
#2
|
|||
|
|||
|
easy!
PHP Code:
Code:
"SELECT date FROM table WHERE DAY(date) = '$day' ORDER BY date"; "SELECT date FROM table WHERE MONTH(date) = '$month' ORDER BY date"; "SELECT date FROM table WHERE YEAR(date) = '$year' ORDER BY date";
__________________
-- Jason |
|
#3
|
|||
|
|||
|
excuse the ignorance, could you elaborate a little for me please.
Thanks, Jon |
|
#4
|
|||
|
|||
|
what is your db column type for date? is it a datetime?
if so, you can use mysql's built in "search" features by selecting a portion of the date through your select statement. |
|
#5
|
||||
|
||||
|
Have her insert a full date into a date field. The format is YYYY-MM-DD. Then you can just add "ORDER BY datefield DESC" to your query. No need to do multiple queries.
|
|
#6
|
|||
|
|||
|
sorted!
Thanks to everyone that answered, got it working a treat now.
Jon |
|
#7
|
|||
|
|||
|
Moved this topic into the MySQL forum. Figured it would be best suited here
![]() |
|
#8
|
|||
|
|||
|
Order by Current Date and not timestamp
reposted
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > order by date (not UNIX timestamp) php/mysql |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|