SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist spoondevil's Avatar
    Join Date
    Jun 2001
    Location
    Harlow, Essex, UK
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SELECT Entries from This Week & This Month

    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

  2. #2
    SitePoint Member
    Join Date
    Nov 2004
    Location
    India
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not able to understand what you are exactly trying to say,

    can u just explain a bit more

  3. #3
    SitePoint Evangelist spoondevil's Avatar
    Join Date
    Jun 2001
    Location
    Harlow, Essex, UK
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need to be able to create a link which activates a query to only select certain records from a database.

    I need PHP to work out when the last Monday was and generate this date into a YYYY-MM-DD format, unless today is a Monday then use todays date.

    I need PHP to work out when the 1st of the month was and generate this date into a YYYY-MM-DD format.


    This probably makes a lot more sense!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •