我有一个包含数据的学术表。请帮我解决这个问题
例如:
试试这个:
<table border="1">
<tr>
<th>Degree</th>
<th>Diploma</th>
<th>Post Diploma</th>
</tr>
<?php
$stmt = $conn->prepare("SELECT
MAX(CASE WHEN level = 'Degree' THEN percentage END) AS Degree,
MAX(CASE WHEN level = 'Diploma' THEN percentage END) AS Diploma,
MAX(CASE WHEN level = 'Post Diploma' THEN percentage END) AS Post_Diploma
FROM tbl_academic_qualification WHERE member_no = :emp_id");
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>";
echo "<td>" . $row['Degree'] . "</td>";
echo "<td>" . $row['Diploma'] . "</td>";
echo "<td>" . $row['Post_Diploma'] . "</td>";
echo "</tr>";
}
?>
</table>