| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 | 
							- <?php
 
- class tables
 
- {
 
-   private $way_to_files = '/home/last_php_task13.hostfl.ru/public_html';
 
-   private $dbname='last_php_task13';
 
-   private $host='127.0.0.1';
 
-   private $password='iVubC3J5';
 
-   private $user='last_php_task13';
 
- public function aaaa()
 
- {
 
-   echo('aaAaaa');
 
- }
 
- public function create_table($mas)
 
- 	{
 
- 	$a=0;
 
-    try 
 
-       {
 
-           $db = new PDO("mysql:host=$this->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`)<NOW()';
 
-     }
 
-       if(isset($mas['time_of_tasks']))
 
-         {
 
-           if($mas['time_of_tasks']=='OnDate' and isset($mas['date_of_tasks']))
 
-           {
 
-             $check=$db->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`)<NOW()".$addit);
 
-           }
 
-         	else
 
-           if($mas['time_of_tasks']=='LastMonth')
 
-           {
 
-               $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']=='Today')
 
-         	{
 
-           	$check=$db->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 '<tr background-color=grey>';
 
- 			  else
 
- 				  echo '<tr>';
 
- 			  echo '<td>'.$mas_of_file['id'].'</td>
 
-               <td>'.$mas_of_file['theme'].'</td>
 
-               <td>'.$mas_of_file['type'].'</td>
 
-               <td>'.$mas_of_file['place'].'</td>
 
-               <td>'.substr($mas_of_file['date_time_start'],0,-3).'</td>
 
-               <td>'.substr($mas_of_file['date_time_end'],0,-3).'</td>
 
-               <td>'.$mas_of_file['comment'].'</td>
 
-               <td>'.$mas_of_file['status'].'</td>
 
-               <td><input type="radio" value="'.$mas_of_file['id'].'" name="change">редактировать</td>
 
-               </tr>';
 
- 			}
 
-   		
 
- 		}
 
- 	}
 
-   /*
 
-   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;
 
- */
 
- }
 
- ?>
 
 
  |