Getting last months data from database |
Hi there,
I am trying to work out how I can get the previous months results from my database. This is what I have so far but I just cannot figure out what should be in the where line. PHP Code: public function get_last_month(){ Can anyone help please? Thanks, Doomie
(08-25-2016, 08:34 AM)Hi Doomie22,here is the solution for getting last month data: Wrote:
First, try to get the month number AND year from the previous month.
PHP Code: $pm = (int) date('n', strtotime('-1 months')); Now you're ready to build your query: PHP Code: public function get_last_month(){ Hope this will help. (08-25-2016, 11:39 AM)Wouter60 Wrote: First, try to get the month number AND year from the previous month. This worked perfectly. Thank you so much. |
Welcome Guest, Not a member yet? Register Sign In |