MYSQL 将行提取到不同的表

MYSQL fetching rows to different tables

我遇到了以下问题。我有 table 多个记录。每行代表某种新闻,因此我需要将它们彼此区分开来。这样做的方法是为这些新闻中的每一个(或某种包装器)制作一个 table,但是我遇到了将每个结果提取到每个 table(包装器)的问题。
我不知道如何告诉 SQL 将记录分开。下面是我的代码块,以及 table 的设计。

.news{
    width:400px;
    height:auto;
    border: 1px solid red;
    float:left;
}

.news tr:first-child{
    font-weight: bold;
    height:40px;
    text-align: center;
}
.news tr:last-child{
    background-color: whitesmoke;
    height: 200px;
    padding-bottom: auto;
    text-align: center;
}
.details td{
    width:200px;
    height: 40px;
    text-align: center;
}
echo "<table class='news'>";
    while ($row = mysqli_fetch_array($result)) {
        echo "<tr>
                <td colspan='2'>
                    $row[0]
                </td>
            </tr>
            <tr class='details'>
                <td>
                    $row[1]
                </td>
                <td>
                    $row[2]
                </td>
            </tr>    
            <tr>    
                <td colspan='2'>
                    $row[3]
                </td>
            </tr>";
        echo "</table>";
    }

$query = " SELECT headline, date, concat (firstName,' ',lastName), body FROM "
        . "school_info natural join teachers ORDER BY id_school_inf DESC LIMIT 2;";
$result = mysqli_query($conn, $query);

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^这是我的查询。有一个限制,所以我总是可以获取最新的(比如最近 5 条)新闻。
任何帮助将不胜感激

您需要为您拥有的每种类型的记录创建单独的 table?很简单,如果您 order 您的记录类型:

SELECT * FROM whatever ORDER BY type_of_record

然后

$previous = null;
while(... fetch from db ...) {
    if ($row['type'] != $previous) {
         ... got new record type, start new table 
    }
    ... display row
    $previous = $row['type']; // store current type for comparison later
}