【发布时间】:2016-10-25 16:31:11
【问题描述】:
我已经尝试了很多方法来让这张表格打印得尽可能好,但我失败了。
我知道这很简单,所以我希望你能帮助我。
这是我的代码:
<?php
include('../connect.php');
$id=$_SESSION['login_user'];
$sql = "Select CourseName , Studentname from course p natural join student t";
$rs_result = mysql_query ($sql, $connection);
echo "<center>";
echo "<table>";
echo "<tr> <th>Course Name</th> <th> Students Name</th> </tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $rs_result )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['CourseName'] . '</td>';
echo "<td rowspan=''> $row[Studentname] </td> ";
echo "</tr>";
}
echo "</table>";
echo "</center>";
?>
我想成为这样的人
Course | Name | Student name |
Math101 | john, Mike |
...
另外,两个表之间的 JOIN 查询是否正确?
这两个表是:
课程(课程名称 - 课程 ID)
学生(学生姓名 - 课程 ID)
【问题讨论】:
-
你能告诉我你需要什么确切的输出
-
“名称”列指的是什么?您描述的“学生”表不包含此类字段。以及“课程”表。
-
名称 = 课程名称! .. 输出显示课程名称和学生姓名(一行中所有参加此课程的学生姓名)
标签: php database html-table