diff($past); $chosen_date = $today; $days_range1 = $interval->days; $days_range2 = 0; // Do some ajax stuff if (isset($_POST['range1'])) { $range1 = $_POST['range1']; $range2 = $_POST['range2']; $choice1 = new DateTime($range1); $interval = $today_date->diff($choice1); $days_range1 = $interval->days; $choice2 = new DateTime($range2); $interval = $today_date->diff($choice2); $days_range2 = $interval->days; $year_ago = $range1; $today = $range2; } $query = "SELECT COUNT(shop_id) as total_shops from shops WHERE (date >= DATE_SUB(CURDATE(),INTERVAL $days_range1 DAY) AND date <= DATE_SUB(CURDATE(), INTERVAL $days_range2 DAY));"; $shop_totals_sql = mysql_query($query, $YBDB) or die(mysql_error()); $query = "SELECT shop_type, COUNT(shop_id) AS shop_totals from shops LEFT JOIN shop_types ON shops.shop_type = shop_types.shop_type_id WHERE (date >= DATE_SUB(CURDATE(),INTERVAL $days_range1 DAY) AND date <= DATE_SUB(CURDATE(), INTERVAL $days_range2 DAY)) GROUP BY shop_type ORDER BY shop_totals DESC;"; $shop_totals_by_types_sql = mysql_query($query, $YBDB) or die(mysql_error()); ?>
Totals for Shop Openings
Type
Totals


Date Range: