我无法让这个查询工作。它只显示第一个数据库条目。任何想法都非常感谢。
/* 准备 */
$sql = "SELECT personal.firstName, personal.lastName, etc.
FROM personal
LEFT JOIN exam
ON personal.P_ID=exam.P_ID
LEFT JOIN contact
ON exam.P_ID=contact.P_ID
WHERE exam.Level = ?
AND exam.Centre!='' ORDER BY exam.Centre";
$stmt = $db->prepare($sql);
/* 执行 */ $stmt->execute(array($level));
/* Fetch */
$row = $stmt->fetch(PDO::FETCH_ASSOC);
/* Display */
echo '<table>
<tr>
<td>Name</td>
<td>Surname</td>
<td>Paid?</td>
<td>Etc</td>
<td>Etc</td>
<td>Etc</td>
</tr>';
if ($row) { foreach ($row as $key => $value)
{
echo '<td>';
echo $value;
echo '</td>';
}
echo '</tr>';
}
echo '</table>';