TGM Posted May 10, 2009 Share Posted May 10, 2009 I have a restaurant database and I want to display the all the orders made by the day. How can I report all orders made by the day using the date. On my order table I have a date/time that shows the time n date of the order made... Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/ Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 SELECT * FROM table WHERE DATE_SUB(CURDATE(), INTERVAL 1 DAY) <= date; ? Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831106 Share on other sites More sharing options...
TGM Posted May 10, 2009 Author Share Posted May 10, 2009 SELECT * FROM table WHERE DATE_SUB(CURDATE(), INTERVAL 1 DAY) <= date; ? doesnt work...any other way how to do it Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831152 Share on other sites More sharing options...
.josh Posted May 10, 2009 Share Posted May 10, 2009 how about posting how you tried to implement that solution. Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831154 Share on other sites More sharing options...
TGM Posted May 10, 2009 Author Share Posted May 10, 2009 how about posting how you tried to implement that solution. $result = mysql_query ("SELECT * FROM orders WHERE date_time(CURDATE(), INTERVAL 1 DAY) <= date "); This one below work but it displays all orders and I want on orders made per day! $result = mysql_query ("SELECT * FROM orders ORDER BY `date_time` "); Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831163 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 Change date to date_time? Ever thought of that? Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831165 Share on other sites More sharing options...
TGM Posted May 10, 2009 Author Share Posted May 10, 2009 Change date to date_time? Ever thought of that? date_time -->is the field name on my table Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831170 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 Yeah I know. So do you see anything wrong with this: $result = mysql_query ("SELECT * FROM orders WHERE date_time(CURDATE(), INTERVAL 1 DAY) <= date "); ? You did post it a few posts up. Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831174 Share on other sites More sharing options...
TGM Posted May 10, 2009 Author Share Posted May 10, 2009 Yeah I know. So do you see anything wrong with this: $result = mysql_query ("SELECT * FROM orders WHERE date_time(CURDATE(), INTERVAL 1 DAY) <= date "); ? You did post it a few posts up. THis works but is doing it manually and it only displays 1 order.. Im trying to display all orders made by a day. example display all orders made on '2009-05-10' $result = mysql_query ("SELECT * FROM orders WHERE `date_time`='2009-05-10 03:36:02' "); Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831179 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 Well, here's the breakdown. 1. You replaced my DATE_SUB MySQL function with date_time. 2. You should replace date (at the end) with date_time instead. 3. Last, but certainly *NOT* least, Google! Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831181 Share on other sites More sharing options...
TGM Posted May 10, 2009 Author Share Posted May 10, 2009 Well, here's the breakdown. 1. You replaced my DATE_SUB MySQL function with date_time. 2. You should replace date (at the end) with date_time instead. 3. Last, but certainly *NOT* least, Google! tnx it works but still doesnt give me what I want..It still displays all the orders from different days. $result = mysql_query ("SELECT * FROM orders WHERE DATE_SUB(CURDATE(), INTERVAL 1 DAY) <= `date_time` "); Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831200 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 Oh oops. My bad. Change that 1 in INTERVAL 1 DAY to 0. Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831210 Share on other sites More sharing options...
TGM Posted May 10, 2009 Author Share Posted May 10, 2009 Oh oops. My bad. Change that 1 in INTERVAL 1 DAY to 0. nice works now...jus one last question how would I display all orders made on a month...would changing the Interval be best way to do it. Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831224 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 INTERVAL 1 MONTH? Quote Link to comment https://forums.phpfreaks.com/topic/157614-solved-displays-in-php/#findComment-831227 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.