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
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.

Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.