基本上,我正在表中的一个项目上工作,如果出现了课程ID,并且在这些课程ID下出现了学生姓名。 您可以看到这张图片
数据已获取但无法完美放置。谁能帮我吗?
<div class="container">
<div class="row main-center">
<div class="col-md-12">
<h4 style="Text-align:center">Teacher Name : <span></span></h4>
</div>
</div>
<div class="row main">
<div class="main-login main-center">
<table class="table table-dark">
<thead>
<tr>
<?php foreach ($mydata as $data) {?>
<th scope="col"><?php echo $data->COURSE_ID?></th>
<!-- <th scope="col">Status</th> <th scope="col">Action</th> -->
<?php }?>
</tr>
</thead>
<tbody>
<?php foreach ($mydata as $data) {?>
<tr>
<td><?php echo $data->FIRST_NAME ." ".$data->LAST_NAME; ?></td>
</tr> <?php } ?>
</tbody>
</table>
<?php echo $this->pagination->create_links(); ?>
</div>
thats my code of html
$query = $this->db->query("
SELECT teacher_registration.COURSE_ID,
student.FIRST_NAME,
student.LAST_NAME
FROM teacher_registration left outer JOIN student_registration ON
teacher_registration.COURSE_ID = student_registration.COURSE_ID
left outer JOIN student ON
student.OEN_NUMBER = student_registration.OEN_NUMBER
WHERE
teacher_registration.REG_ID =".$id
);
多数民众赞成在我的查询中获取数据。
答案 0 :(得分:0)
<div class="container">
<div class="row main-center">
<div class="col-md-12">
<h4 style="Text-align:center">Teacher Name : <span></span></h4>
</div>
</div>
<div class="row main">
<div class="main-login main-center">
<table class="table table-dark">
<thead>
<tr>
<?php foreach ($mydata as $data) {?>
<th scope="col"><?php echo $data->COURSE_ID?></th>
<!-- <th scope="col">Status</th> <th scope="col">Action</th> -->
<?php }?>
</tr>
</thead>
<tbody>
<tr>
<?php foreach ($mydata as $data) {?>
<td><?php echo $data->FIRST_NAME ." ".$data->LAST_NAME; ?></td>
</tr>
</tbody>
</table>
<?php echo $this->pagination->create_links(); ?>
</div>
循环必须在<tr>
内,才能放在同一行
答案 1 :(得分:0)
如果行...只是迭代表单元格(td)...
<tbody>
<tr>
<?php foreach ($mydata as $data) {?>
<td><?php echo $data->FIRST_NAME ." ".$data->LAST_NAME; ?></td>
<?php } ?>
</tr>
</tbody>