#include <iostream>
#include <chrono>
using namespace std::chrono;
int main() {
auto start = system_clock::now();
while (duration_cast<seconds>(system_clock::now() - start).count() < 5)
;
// It is now 5 seconds later.
}
如何消除相同的提取数据并仅回显一个?谢谢
我在这里想要做的是在学校里感谢mos违反了规则
答案 0 :(得分:0)
如果您希望所有违规行为从最严重到最不严重
$s_stud = $con->query("SELECT violation_type, count(violation_type) as num_violations
FROM violations_tbl
GROUP BY violation_type
ORDER BY num_violations DESC");
while($row= $s_stud->fetch_assoc() ){
//echo the violation and the count
if($row['num_violations'] > 1 ){
echo "<tr>";
echo "<td>$row[violation_type]</td>";
echo "<td>$row[num_violations]</td>";
echo "</tr>";
}
}
如果只希望违反MOST,则可以在查询中添加LIMIT 1
并删除循环。
$s_stud = $con->query("SELECT violation_type, count(violation_type) as num_violations
FROM violations_tbl
GROUP BY violation_type
ORDER BY num_violations DESC
LIMIT 1");
$row= $s_stud->fetch_assoc();
//echo the violation and the count
echo "<tr>";
echo "<td>$row[violation_type]</td>";
echo "<td>$row[num_violations]</td>";
echo "</td></tr>";