<?php
$gett = $_GET["q"];//获取数据
$selectTimeMin = $_GET['selectTimeMin'];
$selectTimeMax = $_GET['selectTimeMax'];
ini_set("precision", "3");  //浮点数小数位数
   class MyDB extends SQLite3
   {
      function __construct()
      {
			//$this->open('C:/Users/Administrator/Desktop/workFile/ElecWaterPrj/水文协议SL651 配置软件20220120/DB/SL651.sqlite.db3');
			$this->open('C:/Users/Administrator/Desktop/workFile/HlsPrj/河流_50888/DB/SL651.sqlite.db3');
      }
   }
   $con = new MyDB();
   if(!$con){
      echo $con->lastErrorMsg();
   } 
   
// 选择数据库
$sql="SELECT * FROM waterLayerInfo WHERE dataTime > '$selectTimeMin' and dataTime < '$selectTimeMax' and devID = '".$gett."' ORDER by `dataTime` DESC LIMIT 10;";
$result = $con->query($sql);
//echo $sql;
if (!$result) {
    printf("Error: SELECT DB ERR\n");
	$con->close();
    exit();
}
echo "<table border='1'>
<tr>
<th>序号</th>
<th>采集时间</th>
<th>上报时间</th>
<th>设备ID</th>
<th>电压</th>
<th>电流</th>
<th>系统报警状态</th>
<th>温度</th>
<th>运行时间</th>
<th>传感器位置</th>
<th>PowerOn_H</th>
<th>DevOnline_H</th>
<th>DevState_H</th>
<th>DevAlarm_H</th>
<th>iCur_H</th>
<th>MoterClcPosition_H</th>
<th>IntervalDis_H</th>
<th>MotorStatus_H</th>
<th>CurLayer_H</th>
<th>MotorDirection_H</th>
<th>RES_H</th>
<th>PowerOn_V</th>
<th>DevOnline_V</th>
<th>DevState_V</th>
<th>DevAlarm_V</th>
<th>iCur_V</th>
<th>MoterClcPosition_V</th>
<th>IntervalDis_V</th>
<th>MotorStatus_V</th>
<th>CurLayer_V</th>
<th>MotorDirection_V</th>
<th>RES_V</th>
<th>PowerOn_L</th>
<th>DevOnline_L</th>
<th>DevState_L</th>
<th>DevAlarm_L</th>
<th>iCur_L</th>
<th>MoterClcPosition_L</th>
<th>IntervalDis_L</th>
<th>MotorStatus_L</th>
<th>CurLayer_L</th>
<th>MotorDirection_L</th>
<th>RES_L</th>
<th>PowerOn_W</th>
<th>RES_W</th>
<th>采样瓶状态</th>
<th>RES_1</th>
<th>RES_2</th>
<th>RES_3</th>
<th>RES_4</th>
</tr>";

// SELECT 操作
while($row = $result->fetchArray(SQLITE3_ASSOC)) {
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['dataTime'] . "</td>";
    echo "<td>" . $row['reportTime'] . "</td>";
    echo "<td>" . $row['devID'] . "</td>";
    echo "<td>" . $row['Vol'] . "</td>";
    echo "<td>" . $row['iCur'] . "</td>";
    echo "<td>" . $row['SysAlarmState'] . "</td>";
    echo "<td>" . $row['Temperature'] . "</td>";
    echo "<td>" . $row['Runtime'] . "</td>";
    echo "<td>" . $row['SensorPosition'] . "</td>";
    echo "<td>" . $row['PowerOn_H'] . "</td>";
    echo "<td>" . $row['DevOnline_H'] . "</td>";
    echo "<td>" . $row['DevState_H'] . "</td>";
    echo "<td>" . $row['DevAlarm_H'] . "</td>";
    echo "<td>" . $row['iCur_H'] . "</td>";
    echo "<td>" . $row['MoterClcPosition_H'] . "</td>";
    echo "<td>" . $row['IntervalDis_H'] . "</td>";
    echo "<td>" . $row['MotorStatus_H'] . "</td>";
    echo "<td>" . $row['CurLayer_H'] . "</td>";
    echo "<td>" . $row['MotorDirection_H'] . "</td>";
    echo "<td>" . $row['RES_H'] . "</td>";
    echo "<td>" . $row['PowerOn_V'] . "</td>";
    echo "<td>" . $row['DevOnline_V'] . "</td>";
    echo "<td>" . $row['DevState_V'] . "</td>";
    echo "<td>" . $row['DevAlarm_V'] . "</td>";
    echo "<td>" . $row['iCur_V'] . "</td>";
    echo "<td>" . $row['MoterClcPosition_V'] . "</td>";
    echo "<td>" . $row['IntervalDis_V'] . "</td>";
    echo "<td>" . $row['MotorStatus_V'] . "</td>";
    echo "<td>" . $row['CurLayer_V'] . "</td>";
    echo "<td>" . $row['MotorDirection_V'] . "</td>";
    echo "<td>" . $row['RES_V'] . "</td>";
    echo "<td>" . $row['PowerOn_L'] . "</td>";
    echo "<td>" . $row['DevOnline_L'] . "</td>";
    echo "<td>" . $row['DevState_L'] . "</td>";
    echo "<td>" . $row['DevAlarm_L'] . "</td>";
    echo "<td>" . $row['iCur_L'] . "</td>";
    echo "<td>" . $row['MoterClcPosition_L'] . "</td>";
    echo "<td>" . $row['IntervalDis_L'] . "</td>";
    echo "<td>" . $row['MotorStatus_L'] . "</td>";
    echo "<td>" . $row['CurLayer_L'] . "</td>";
    echo "<td>" . $row['MotorDirection_L'] . "</td>";
    echo "<td>" . $row['RES_L'] . "</td>";
    echo "<td>" . $row['PowerOn_W'] . "</td>";
    echo "<td>" . $row['RES_W'] . "</td>";
    echo "<td>" . $row['tSampleBottle_status'] . "</td>";
    echo "<td>" . $row['RES_1'] . "</td>";
    echo "<td>" . $row['RES_2'] . "</td>";
    echo "<td>" . $row['RES_3'] . "</td>";
    echo "<td>" . $row['RES_4'] . "</td>";
    echo "</tr>";
}
echo "</table>";


$con->close();
 ?>