Hi... Good day! I have table that has a field from_date and to_date. Now I just want to know if how can I display as table format the dates between from_date to_date. Like this from_date: 2011-12-16 to_date: 2011-12-31 I want to display it: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 // table format. Thank you
Something like this should do the trick, though it breaks if days are in single characters eg: if 7th was just 'Y-M-7' , format needs to be 'Y-M-07' <?php //---------------------------------------------------------------------------------------- function dates_range($dateA, $dateB) { if ($dateA<$dateB) { $dates_range[]=$dateA; $dateA=strtotime($dateA); $dateB=strtotime($dateB); while ($dateA!=$dateB) { $dateA=mktime(0, 0, 0, date("m", $dateA), date("d", $dateA)+1, date("Y", $dateA)); $dates_range[]=date('Y-m-d', $dateA); } } return $dates_range; } //---------------------------------------------------------------------------------------- /* usage: */ $from_date = "2011-12-16"; #Note: days need two digits eg: for 7th would be: 07 etc. $to_date = "2011-12-31"; $array = dates_range($from_date, $to_date); foreach($array as &$val) { $val = substr($val, -2); #extract days (last two chars) } unset($val); #free up buffer echo implode(" ", $array); ?> PHP:
select COUNT(UserID) from prayer WHERE date BETWEEN CURDATE() and DATE_SUB(CURDATE(),INTERVAL -14 DAY); Update this query....as per your requirement....