是否可以从行内容中过滤/分离来自 PHP 中 MySQL 的数据?

Is it possible to Filter / Seperate Data from MySQL in PHP from a rows content?

我想要实现的是一种从给定行中的值过滤 table 结果的方法。

例如:如果我有多个学校的上课时间 table。我想从 table 中获取所有数据,然后将其分离到学校中。

那么最好的方法是什么才能在网页上用 header 分隔不同字段的数据,例如用 header 学校名称分隔学校?

我想首先最好使用 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'];
}