php - show results of last six months -


i'd show results of sql query of last 6 months, , show month , year of results, code i'll show isn't complete because in fact it's longer i've tried give important parts.. used function returns query ( parameter $k interval...):


i have loop increments $k can make query 6 months:

for($i=0;$i<=5;$i++){         $requete = query($i);         sql_query($requete); // function executes query     }        

i can results of last months untill january not december because year 2012 not 2013.


i've tried make year current year -1 when month 12:

function print_date($y_m){         foreach($y_m $row){              echo $row[0];         if ($row[0] == 12){              $_session["y"]= $_session["y"]+1;              echo $_session["y"];         } } 

but it's not working, :/ have idea how able ??

you can data last 6 month simple sql query this:

select src source mytable type = 'sms'      , date >= date_sub(now(), interval 6 month) 

extends

if nedd 1 month may modify query:

select src source mytable type = 'sms'      , year(date) = date_sub(now(), interval $k month)     , month(date) = date_sub(now(), interval $k month) 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -