host;dbname=$this->dbname", $this->user, $this->password); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->exec("set names utf8"); //echo('database connected '); } catch(PDOException $e) { echo $e->getMessage(); return; } $number = $db->query("SELECT MAX(`id`) FROM `tasks` WHERE 1"); $r=$number->fetch(); $n=$r['MAX(`id`)']; $nnnaa=0; $addit=''; if(isset($mas['type_of_tasks'])) { if($mas['type_of_tasks']=='Made') $addit=' AND `status`="done"'; if($mas['type_of_tasks']=='NotMade') $addit=' AND `status`="undone" AND DATE(`date_time_end`)prepare("SELECT * FROM `tasks` WHERE `id`=:id and DATE(`date_time_start`)=:date".$addit); $nnnaa=1; } else if($mas['time_of_tasks']=='LastWeek') { $check=$db->prepare("SELECT * FROM `tasks` WHERE `id`=:id and DATE(`date_time_start`)>=NOW()-INTERVAL 7 DAY AND DATE(`date_time_start`)prepare("SELECT * FROM `tasks` WHERE `id`=:id and DATE(`date_time_start`)>=NOW()-INTERVAL 1 MONTH AND DATE(`date_time_start`)prepare("SELECT * FROM `tasks` WHERE `id`=:id and DATE(`date_time_start`)=NOW()".$addit); } else if($mas['time_of_tasks']=='AllTime') { $check = $db->prepare("SELECT * FROM `tasks` WHERE `id`=:id".$addit); } else if($mas['time_of_tasks']=='NextMonth') { $check=$db->prepare("SELECT * FROM `tasks` WHERE `id`=:id and DATE(`date_time_start`)<=NOW()+INTERVAL 1 MONTH AND DATE(`date_time_start`)>NOW()".$addit); } else if($mas['time_of_tasks']=='NextWeek') { $check=$db->prepare("SELECT * FROM `tasks` WHERE `id`=:id and DATE(`date_time_start`)<=NOW()+INTERVAL 7 DAY AND DATE(`date_time_start`)>NOW()".$addit); } else if($mas['time_of_tasks']=='Yesterday') { $check=$db->prepare("SELECT * FROM `tasks` WHERE `id`=:id and DATE(`date_time_start`)=NOW()-INTERVAL 1 DAY".$addit); } else if($mas['time_of_tasks']=='Tomorrow') { $check=$db->prepare("SELECT * FROM `tasks` WHERE `id`=:id and DATE(`date_time_start`)=NOW()+INTERVAL 1 DAY".$addit); } } else $check = $db->prepare("SELECT * FROM `tasks` WHERE `id`=:id"); for($id=1; $id<=$n; $id++) { if($nnnaa===0) $check->execute(array('id'=>$id)); else $check->execute(array('id'=>$id, 'date'=>$mas['time_of_task'])); $mas_of_file = $check->fetch(PDO::FETCH_ASSOC); if(isset($mas_of_file['id'])) { $a=$a+1; if($a%2==1) echo ''; else echo ''; echo ''.$mas_of_file['id'].' '.$mas_of_file['theme'].' '.$mas_of_file['type'].' '.$mas_of_file['place'].' '.substr($mas_of_file['date_time_start'],0,-3).' '.substr($mas_of_file['date_time_end'],0,-3).' '.$mas_of_file['comment'].' '.$mas_of_file['status'].' редактировать '; } } } /* CREATE TABLE `tasks` ( `id` int(10) AUTO_INCREMENT NOT NULL, `theme` varchar(255) NOT NULL, `type` varchar(255) NOT NULL, `place` varchar(255) DEFAULT NULL, `date_time` datetime DEFAULT NULL, `long` int(10) DEFAULT NULL, `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; */ } ?>