我想要实现的是一种从给定行中的值过滤表中结果的方法。
例如:如果我有一个多所学校的上课时间表。我想从表中获取所有数据,然后将其单独放入学校。
那么,在网页上可以通过不同字段的标题分隔数据(例如用学校名称标题分隔学校),最好的方法是什么?
最佳答案
我想首先最好使用 GROUP BY 函数或至少 ORDER 函数来扩展 SQL 查询。之后,您必须在 php 代码中进行所谓的组更改,如以下示例代码所示:
$school = '';
foreach ($data as $row) {
// here 's the group change
if ($school != $row['school_name'])) {
$school = $row['school_name'];
// header output
echo $row['school_name'];
}
// output of the other data
echo $row['blah'];
}
关于javascript - 是否可以从行内容中过滤/分离 PHP 中的 MySQL 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29943407/