MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old October 9th, 2003, 07:11 AM
jben.net jben.net is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 51 jben.net User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 41 sec
Reputation Power: 6
Send a message via AIM to jben.net
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

Reply With Quote
  #2  
Old October 9th, 2003, 08:34 AM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 364 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 26 sec
Reputation Power: 6
easy!

PHP Code:
 $day date"j" );
$month date"F" );
$year date"Y" ); 

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

Reply With Quote
  #3  
Old October 9th, 2003, 08:38 AM
jben.net jben.net is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 51 jben.net User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 41 sec
Reputation Power: 6
Send a message via AIM to jben.net
excuse the ignorance, could you elaborate a little for me please.

Thanks,

Jon

Reply With Quote
  #4  
Old October 9th, 2003, 08:47 AM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 364 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 26 sec
Reputation Power: 6
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.

Reply With Quote
  #5  
Old October 9th, 2003, 08:49 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
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.

Reply With Quote
  #6  
Old October 9th, 2003, 10:16 AM
jben.net jben.net is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 51 jben.net User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 41 sec
Reputation Power: 6
Send a message via AIM to jben.net
sorted!

Thanks to everyone that answered, got it working a treat now.

Jon

Reply With Quote
  #7  
Old October 9th, 2003, 06:37 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 364 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 26 sec
Reputation Power: 6
Moved this topic into the MySQL forum. Figured it would be best suited here

Reply With Quote
  #8  
Old April 23rd, 2007, 10:12 PM
devain devain is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 devain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 56 m 50 sec
Reputation Power: 0
Order by Current Date and not timestamp

reposted

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > order by date (not UNIX timestamp) php/mysql


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway