I've developed a script for a customer so he can input all his shop sales to make life easier when it comes to the accounts, but he also wants to see running totals of Today, This Week [From Monday], This Month [From 1st of Month], Specfied Date & All

I am currently using this query:
PHP Code:
Todays:
 
SELECT sale_iddate_format(date_of_sale'%e %M') as date_of_salecategorybrandstylepricediscounttotalextra_info FROM sales WHERE date_of_sale curdate() ORDER BY date_of_sale ASC
    
  Specified Date
:
 
SELECT sale_iddate_format(date_of_sale'%e %M') as date_of_salecategorybrandstylepricediscounttotalextra_info FROM sales WHERE date_of_sale '%s' ORDER BY date_of_sale ASC
   
   All
:
 
SELECT sale_iddate_format(date_of_sale'%e %M') as date_of_salecategorybrandstylepricediscounttotalextra_info FROM sales ORDER BY date_of_sale ASC 
I need to know how to get PHP to sort out the date in the link so I can create ones such as viewsales.php?week=2004-11-2004 & viewsales.php?month=2004-12-01, I could then use a query such as:
PHP Code:
SELECT sale_iddate_format(date_of_sale'%e %M') as date_of_salecategorybrandstylepricediscounttotalextra_info FROM sales WHERE date_of_sale >= '%s' ORDER BY date_of_sale ASC 
So I now need PHP to be able to break down the date to create these links in the first place. Something like this for the weekly links:
PHP Code:
Get CURDATE()
      IF 
$today monday {
          use 
$today $date
      
} ELSE IF $today tuesday {
              use 
$today $date
      
} ELSE IF today Wednesday {
              use 
$today $date
      
} ELSE IF today Thursday {
              use 
$today $date
      
} ELSE IF today Friday {
              use 
$today $date
      
} ELSE IF today Saturday {
              use 
$today $date
      
} ELSE IF today Sunday {
              use 
$today $date
      
}
  
  
viewsales.php?week=$date 
Not sure how the monthly links would work, but it needs to round down the dates from, for example:
PHP Code:
2004-12-01 to 2004-12-00
    2004
-12-27 to 2004-12-00
    2005
-01-13 to 2004-01-00 
Hope this makes sense to someone!


Ta
Gunter