Jump to content

php simple monthly report


rami103

Recommended Posts

hi friends i need lil help in php reports i have a sales tabel where i have sale_id and sale_price and date_added columns i want to show a chart on my page showing last 6 months with number of sales can someone suggest me or give me some example how i can do i have chart code but i dont know how i can get last 6 months with number of sales from database

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/205355-php-simple-monthly-report/
Share on other sites

hi friends i need lil help in php reports i have a sales tabel where i have sale_id and sale_price and date_added columns i want to show a chart on my page showing last 6 months with number of sales can someone suggest me or give me some example how i can do i have chart code but i dont know how i can get last 6 months with number of sales from database

 

thanks

 

SQL query, using your date_added column.

in your SQL query, in the Where clause, you need something like this WHERE (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`date_added`)) < (60*60*24*182)

 

that set of numbers is the number of seconds in half a year (ish)... so whatever you do needs to follows this logic:

 

number of seconds since epoch to right now - number of seconds since epoch to the date added

must be less than

the number of seconds in 1/2 of a year (60 seconds * 60 min * 24 hr * 182 days)

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.