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: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:Todays:
SELECT sale_id, date_format(date_of_sale, '%e %M') as date_of_sale, category, brand, style, price, discount, total, extra_info FROM sales WHERE date_of_sale = curdate() ORDER BY date_of_sale ASC
Specified Date:
SELECT sale_id, date_format(date_of_sale, '%e %M') as date_of_sale, category, brand, style, price, discount, total, extra_info FROM sales WHERE date_of_sale = '%s' ORDER BY date_of_sale ASC
All:
SELECT sale_id, date_format(date_of_sale, '%e %M') as date_of_sale, category, brand, style, price, discount, total, extra_info FROM sales 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:SELECT sale_id, date_format(date_of_sale, '%e %M') as date_of_sale, category, brand, style, price, discount, total, extra_info FROM sales WHERE date_of_sale >= '%s' ORDER BY date_of_sale ASC
Not sure how the monthly links would work, but it needs to round down the dates from, for example:PHP Code:Get CURDATE()
IF $today = monday {
use $today = $date
} ELSE IF $today = tuesday {
use $today - 1 = $date
} ELSE IF today = Wednesday {
use $today - 2 = $date
} ELSE IF today = Thursday {
use $today - 3 = $date
} ELSE IF today = Friday {
use $today - 4 = $date
} ELSE IF today = Saturday {
use $today - 5 = $date
} ELSE IF today = Sunday {
use $today - 6 = $date
}
viewsales.php?week=$date
Hope this makes sense to someone!PHP Code:2004-12-01 to 2004-12-00
2004-12-27 to 2004-12-00
2005-01-13 to 2004-01-00
Ta
Gunter




Bookmarks