Refactored the generation of stats table to be a function with "where"
parameter. 
Now stats.php shows all time stats and last month stats.