dare87 Posted May 14, 2008 Share Posted May 14, 2008 This code is suppost to pull all the data from one date to another, the problem I am having is that the data is mis matching. The date in the db is YYYY-MM-DD and my NOW() is not working. Please Help <?php // This will post the three most current news articles. // Connect to the database. require_once('../../uwmysql_connect.php'); $query = "SELECT title, picurl AS url, details, DATE_FORMAT(start_date, '%M %d, %Y') AS sdate, DATE_FORMAT(end_date, '%M %d, %Y') AS edate FROM mydata WHERE start_date >= NOW() and end_date <= NOW()"; $results = mysql_query($query); if ($results) { // Insert the results. while ($row = mysql_fetch_array($results, MYSQL_ASSOC)) { echo ' <div id="item"><img src="images/' . $row['url'] . '.jpg" alt="' . $row['title'] . '"></div> <br><br><br> <div class="title2">' . $row['title'] . '</div> <div class="datetitle">' . $row['sdate'] . ' - ' . $row['edate'] . '</div> <div class="details">' . $row['details'] . '</div> '; } // Free up the resources. mysql_free_result ($results); } else echo 'There is nothing there!!!!'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/105530-solved-data-convert/ Share on other sites More sharing options...
p2grace Posted May 14, 2008 Share Posted May 14, 2008 Use CURDATE() instead, the returning result will just be the date without the timestamp http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_curdate Quote Link to comment https://forums.phpfreaks.com/topic/105530-solved-data-convert/#findComment-540644 Share on other sites More sharing options...
Barand Posted May 14, 2008 Share Posted May 14, 2008 WHERE start_date >= NOW() and end_date <= NOW() Where start date is in the future and end date is in the past ??? Quote Link to comment https://forums.phpfreaks.com/topic/105530-solved-data-convert/#findComment-540657 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.