表中的行我有這樣的代碼如何修改HTML語言
<html>
<head>
<title> trans </title>
<body>
<style>
table, th, td {
border: 1px solid black;
width: 900px;
margin: auto;
}
h3{
text-align: center;
margin-top: 20px;
}
</style>
<?php
$con = mysqli_connect('localhost', 'root', '');
mysqli_select_db($con,"uoh");
$q = " SELECT * FROM `degree_plan` LEFT JOIN courses ON
degree_plan.course_number=courses.course_number
where major='COE'";
$result = mysqli_query($con , $q) ;
if($result){
echo "<br />";
echo "<table>";
echo "<tr>";
echo "<th>courses</th>";
echo "<th>term_no</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row["code"]. "</td>";
echo "<td>" . $row["term_no"]. "</td>";
echo "</tr>";
}
echo "</table>";
}
?>
</body>
</html>
這個代碼是這樣的輸出。 在這裏,每行都在一行,但我不想那樣。
--------------------------
course term_no
--------------------------
CHEM 101 1
-------------------------
ENGL 101 1
-------------------------
MATH 101 2
--------------------------
PE 101 2
我該如何讓代碼不會分開具有相同term_no的課程。 我想這樣
--------------------------
course term_no
--------------------------
CHEM 101 1
ENGL 101
-------------------------
MATH 101 2
PE 101
你的意思是你想把所有的課程都用同一個term_no分組在一起? –
很可能要首先開始製作一個數組;) –
是的,我想將所有具有相同term_no的課程組合在一起 – Steven