mysqli - set the year before this year - Database - php -


working on since able find year has been there before. is, in 2015 must take have previous year. however, not grasp year in right moment.

only to

printf("<br>i år 2013 var der %d. brænde", $mebe->statistik("2013")); 

it took years 2014 @ 2013, 2015 had both 2013 , 2014 without had add them code somehow did not tackle year in.

the roof database time , date:

2013-05-01 11:13:48

it must such checks year.

function statistik($year=""){            $year=($year !="")? $year : date("y");     $row_cnt=0;     if ($result = $this->mysqli->query("select melding, tidspunkt alarm year(tidspunkt)=$year")) {         $row_cnt = $result->num_rows;                /* close result set */         $result->close();     }        return $row_cnt;     }    

it find out year few years before year.

there many ways accomplish this. example:

$thisyear = date('y', time()); $previousyear = $thisyear - 1; 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -