表中的行我有这样的代码如何修改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