【发布时间】:2019-04-15 19:42:56
【问题描述】:
所以我目前正在使用 PHP 从电子邮件中提取正文、解析数据并将数据插入到用户创建的数据库中。我想使用 PHP 显示数据的概述(即在数据库中)。这是我想要实现的示例:
这是我的桌子:
表名:bldgSensors
sensor_code | temp_limit | current_temp
---------------------------------------
0102260100A | 55 | 45
0102260100B | 55 | 50
0102260100A | 55 | 48
使用 PHP 的期望输出:
Sensors Count
0102260100A 2
0102260100B 1
到目前为止,我可以找到不同的值,但无法输出总数:
$result1 = mysqli_query($DBconn,"SELECT DISTINCT sensor_code FROM bldgSensors");
echo "<table border='1'>
<tr>
<th>Distinct sensor codes</th>
<th>Count</th>
</tr>";
while($row1 = mysqli_fetch_array($result1))
{
echo "<tr>";
echo "<td>" . $row1['sensor_code'] ."</td>";
}
echo "</table>";
mysqli_close($DBconn);
提前非常感谢!这将非常有帮助!
【问题讨论】:
-
那个副本可以顺便说一句。通过将您选择的问题标题逐字复制并粘贴到 Google 中很容易找到……所以请在下次提问之前进行适当的研究。