imarockstar Posted May 11, 2009 Share Posted May 11, 2009 I need to choose the date from a mysql DB and display them using PHP ... my problem is that in the DB the date fields are in this format MONTH . DAY . YEAR .. so basically there is a column for the month for the day and for the year. I need to choose a row based on the date ... but since they are in 2 different columns ... I am not sure how to do that .. this is what I am using now ... $result = mysql_query("SELECT * FROM shows where month < '5' && userid = ". $_SESSION['id']); $showsplayed = mysql_num_rows($result); right now I am selecting the row based on the MONTH only ... but i need to select the row that has the date that is before TODAYS (current date) date ... So i would think I would need t join all 3 columns .. then choose it ? Then I would just echo the data in that row ... im soo confused lol ... any help would be awesome .. Quote Link to comment https://forums.phpfreaks.com/topic/157726-help-with-displaying-variables/ Share on other sites More sharing options...
Maq Posted May 11, 2009 Share Posted May 11, 2009 This seems more like a MySQL issue. Quote Link to comment https://forums.phpfreaks.com/topic/157726-help-with-displaying-variables/#findComment-831886 Share on other sites More sharing options...
fenway Posted May 11, 2009 Share Posted May 11, 2009 You need to properly store your dates using MySQL's DATE column type. You can use STR_TO_DATE() to fix this with a single update statement, and also use this function to format your form input (though a proper date picker won't have this issue whatsoever). Quote Link to comment https://forums.phpfreaks.com/topic/157726-help-with-displaying-variables/#findComment-831888 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.