ansonb Posted February 13, 2012 Share Posted February 13, 2012 I am working on a podcast list script. It displays the results of my mysql query correctly, but shows the results in 1 long list. $query3 = "SELECT * FROM podcasts WHERE show_id = $show_id ORDER BY airdate DESC"; $result3 = mysql_query($query3) or die(mysql_error()); I would like to further filter the results instead of 1 hugely long list. For example, view by year, month etc... The 'airdate' is stored in the database as DATETIME. Is there a way to seperate the parts of the date: year, month, day using php ?? And if so how would I go about displaying only the podcasts for a specific year or month etc. ?? website located at http://www.eliteweboffers.com/lwr/podcasts.php Thanks. Link to comment https://forums.phpfreaks.com/topic/257016-please-help-with-my-podcast-list/ Share on other sites More sharing options...
cyberRobot Posted February 13, 2012 Share Posted February 13, 2012 There are many date/time function built into MySQL: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html For example, if you're looking to show all podcasts since 2011, you could try something like: $sql = "SELECT * FROM podcasts WHERE YEAR(airdate) > 2011"; Link to comment https://forums.phpfreaks.com/topic/257016-please-help-with-my-podcast-list/#findComment-1317612 Share on other sites More sharing options...
ansonb Posted February 14, 2012 Author Share Posted February 14, 2012 Thanks, That helps. So what if I wanted to select all from the last 60 days. Would that be: $sql = "SELECT * FROM podcasts WHERE DATE(airdate) < 60"; Link to comment https://forums.phpfreaks.com/topic/257016-please-help-with-my-podcast-list/#findComment-1317944 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.