如何比较php数据库中的值

时间:2015-09-11 04:41:30

标签: php sql compare

从下表中的表格:

enter image description here

我有没有办法使用nodeID 101作为我的指标。然后我想检索Node102的电池值,该电池值低于NodeID101的电池值...同样转到node103,它也会与node101比较,如果它的电池值低于node101,则显示结果。

感谢您的导游!

<?php

$username="root";
$password="";
$database="testing";
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die("Unable to select database");

$query = "SELECT * FROM monitoring WHERE Battery < 2.7";
$result = mysql_query($query);

echo "<b><center>Database Output</center></b><br><br>";

echo "<table border='1'>
<tr>
<th>PC_Timestamp </th>
<th>NodeID </th>
<th>PacketID </th>
<th>RSSI </th>
<th>Node_Timestamp </th>
<th>Temperature </th>
<th>Battery </th>
</tr>";

while($row = mysql_fetch_array($result)){
    echo "<tr>";
    echo "<td>" . $row['PC_Timestamp'] . "</td>";
    echo "<td>" . $row['NodeID'] . "</td>";
    echo "<td>" . $row['PacketID'] . "</td>";
    echo "<td>" . $row['RSSI'] . "</td>";
    echo "<td>" . $row['Node_Timestamp'] . "</td>";
    echo "<td>" . $row['Temperature'] . "</td>";
    echo "<td>" . $row['Battery'] . "</td>";
    echo "</tr>";
}
echo "</table>";
mysql_close(); 
?>

0 个答案:

没有答案