Web interface and MYSQL structures added
[weathermon.git] / web / index.php
1 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
5   <meta name="GENERATOR" content="Mozilla/4.72 [cp1251] (X11; U; Linux 2.2.12-20smp i686) [Netscape]">    
6   <title>WeatherMon (Последние 24 часа)</title>                      
7   <link rel="icon" href="favicon.png" />
8 </head>
9 <body text="black" bgcolor="silver" link="blue" vlink="#000080" alink="#FF0000">         
10 <?php
11
12 include('config_local.php');
13
14 if (! ($db = new PDO("mysql:host=$mysql_host;port=$mysql_port;dbname=$mysql_schema",$mysql_user,$mysql_pwd,array( PDO::ATTR_PERSISTENT => false)))) {
15   die($err);
16   }  
17
18 $db -> exec('SET CHARACTER SET utf8');
19
20 $q = $db -> prepare(
21   'select 
22     distinct v.sensor_id,s.s_description,p.id as param_id,p.st_description 
23   from 
24     sensor_values v,st_parameters p,sensors s 
25   where 
26     v.timestamp>adddate(now(), -1) 
27     and v.sensor_id=s.id 
28     and s.st_id=p.st_id'
29   );
30 $q -> execute();
31
32 while ($row = $q -> fetch(PDO::FETCH_ASSOC)) {
33
34   echo '<h3 align="center">'.$row['s_description'].'/'.$row['st_description'].'</h3>';
35 ?>
36 <center><img src="image.php?sensor=<?php echo $row['sensor_id']; ?>&param=<?php echo $row['param_id']?>&type=last24"></center>
37 <?php  
38
39 }                                                            
40   
41 ?>
42 <a href="archive.php">Архивные данные</a>
43 <br>
44 <a href="setup.php">Настройки</a>
45 </body>
46