1219 Posted January 17, 2008 Share Posted January 17, 2008 I want to try to sort these results from this page http://www.botkinfuneralservice.com/obituaries/index.php by month in order of calendar year (Jan, Feb,... Dec). How would I do this? $maxRows_DetailRS1 = 25; $pageNum_DetailRS1 = 0; if (isset($_GET['pageNum_DetailRS1'])) { $pageNum_DetailRS1 = $_GET['pageNum_DetailRS1']; } $startRow_DetailRS1 = $pageNum_DetailRS1 * $maxRows_DetailRS1; $colname_DetailRS1 = "-1"; if (isset($_GET['id'])) { $colname_DetailRS1 = $_GET['id']; } mysql_select_db($database_BotkinFuneralHome, $BotkinFuneralHome); $query_DetailRS1 = sprintf("SELECT * FROM onlineObituaries WHERE id = %s ORDER BY last_name ASC", GetSQLValueString($colname_DetailRS1, "int")); $query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $maxRows_DetailRS1); $DetailRS1 = mysql_query($query_limit_DetailRS1, $BotkinFuneralHome) or die(mysql_error()); $row_DetailRS1 = mysql_fetch_assoc($DetailRS1); if (isset($_GET['totalRows_DetailRS1'])) { $totalRows_DetailRS1 = $_GET['totalRows_DetailRS1']; } else { $all_DetailRS1 = mysql_query($query_DetailRS1); $totalRows_DetailRS1 = mysql_num_rows($all_DetailRS1); } $totalPages_DetailRS1 = ceil($totalRows_DetailRS1/$maxRows_DetailRS1)-1; ?> Quote Link to comment https://forums.phpfreaks.com/topic/86560-help-with-sorting-results-by-month/ Share on other sites More sharing options...
Barand Posted January 18, 2008 Share Posted January 18, 2008 ... ORDER BY YEAR(datecolname), MONTH(datecolname) If the data spans less than a year you can leave out the YEAR bit Quote Link to comment https://forums.phpfreaks.com/topic/86560-help-with-sorting-results-by-month/#findComment-442283 Share on other sites More sharing options...
1219 Posted January 18, 2008 Author Share Posted January 18, 2008 It doesn't. It will show all data from 2007, 2008, and so on Quote Link to comment https://forums.phpfreaks.com/topic/86560-help-with-sorting-results-by-month/#findComment-442285 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.