laduch Posted April 8, 2008 Share Posted April 8, 2008 I have a problem with getting the upcoming event work. Upcoming event is the first event in database after the day the site is visited. in mysql database - day, month, year are "d" - int , "m" - int, "y" -int... a example row m d y 12 1 2007 I know it is a bad practice... I'm just using it for temporary I only need to query out one event to database, the script is like: $query = "SELECT *, STR_TO_DATE(CONCAT(y,'-',m,'-',d), '%Y-%c-%e') AS sort_date FROM events WHERE ADDDATE(NOW(), INTERVAL 300 DAY) = STR_TO_DATE(CONCAT(y,'-',m,'-',d), GET_FORMAT(DATE, 'INTERNAL')) ORDER BY sort_date DESC LIMIT 1"; $result = mysql_query($query, $dbconnect); while($row = mysql_fetch_array($result)) { ... Nothing is shown up... although I have about 10 events in the database. Quote Link to comment https://forums.phpfreaks.com/topic/100062-solved-need-help-with-upcoming-event/ Share on other sites More sharing options...
fenway Posted April 8, 2008 Share Posted April 8, 2008 What do you think "STR_TO_DATE(CONCAT(y,'-',m,'-',d), GET_FORMAT(DATE, 'INTERNAL'))" does? Quote Link to comment https://forums.phpfreaks.com/topic/100062-solved-need-help-with-upcoming-event/#findComment-511640 Share on other sites More sharing options...
AndyB Posted April 8, 2008 Share Posted April 8, 2008 Since it's only temporary, scrap the bizarre date method. Store dates using a single field, type DATE - which uses the ISO standard yyyy-mm-dd. Your query (and you life) will be greatly simplified Quote Link to comment https://forums.phpfreaks.com/topic/100062-solved-need-help-with-upcoming-event/#findComment-511641 Share on other sites More sharing options...
laduch Posted April 8, 2008 Author Share Posted April 8, 2008 Can you be specific? I'm kind a starter... Quote Link to comment https://forums.phpfreaks.com/topic/100062-solved-need-help-with-upcoming-event/#findComment-511664 Share on other sites More sharing options...
AndyB Posted April 8, 2008 Share Posted April 8, 2008 Can you be specific? I'm kind a starter... About what? Quote Link to comment https://forums.phpfreaks.com/topic/100062-solved-need-help-with-upcoming-event/#findComment-511682 Share on other sites More sharing options...
laduch Posted April 8, 2008 Author Share Posted April 8, 2008 About how to carry out the query? Quote Link to comment https://forums.phpfreaks.com/topic/100062-solved-need-help-with-upcoming-event/#findComment-511947 Share on other sites More sharing options...
laduch Posted April 8, 2008 Author Share Posted April 8, 2008 Well...I fixed it... just compare int with d,m,y use php's date()... simple and easy... Quote Link to comment https://forums.phpfreaks.com/topic/100062-solved-need-help-with-upcoming-event/#findComment-512228 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.