我有一个包含学生房间作业的数据库表。每个学生都有一个特定的大厅、楼层和公寓。我需要在一个特定的表格中显示每个学生,以便结果看起来像一个楼层布局。下面是一个例子。学生证需要在正确的公寓插槽中。每间公寓可能有多个 ID。现在它只是在页面下方列出它们。
102 号公寓 101 号公寓
104 号公寓 103 号公寓
106 号公寓 105 号公寓
$query = "select res.ID_NUM as ID, res.APARTMENT
From Residents res
Where res.sess_cde = '$pulledsession'
and res.ROOM_ASSIGN_STS = 'A'
and res.BLDG_CDE = '$pulledhall'
and res.FLOOR = '$pulledfloor'";
$result = odbc_exec($connect, $query);
echo "<table style='padding:25;'>
<tr>
<th>Apartment</th>
<th>ID</th>
</tr>";
while(odbc_fetch_row($result)){
$ID = odbc_result($result,ID);
$APARTMENT = odbc_result($result,APARTMENT);
if ($APARTMENT == $pulledfloor.'01')
{
echo "<tr >";
echo "<td>" . $pulledfloor.'01' . "</td>";
echo "<td>" . $ID . "</td>";
echo "</tr>";
}
else if ($APARTMENT == $pulledfloor.'02')
{
echo "<tr>";
echo "<td>" . $pulledfloor.'02' . "</td>";
echo "<td>" . $ID . "</td>";
echo "</tr>";
}
else if ($APARTMENT == $pulledfloor.'03')
{
echo "<tr>";
echo "<td>" . $pulledfloor.'03' . "</td>";
echo "<td>" . $ID . "</td>";
echo "</tr>";
}
else if ($APARTMENT == $pulledfloor.'04')
{
echo "<tr>";
echo "<td>" . $pulledfloor.'04' . "</td>";
echo "<td>" . $ID . "</td>";
echo "</tr>";
}
else if ($APARTMENT == $pulledfloor.'05')
{
echo "<tr>";
echo "<td>" . $pulledfloor.'05' . "</td>";
echo "<td>" . $ID . "</td>";
echo "</tr>";
}
else if ($APARTMENT == $pulledfloor.'06')
{
echo "<tr>";
echo "<td>" . $pulledfloor.'06' . "</td>";
echo "<td>" . $ID . "</td>";
echo "</tr>";
}
}
echo "</table>";