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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -