我想在ci中的表上打印以下数据

问题描述 投票:0回答:2

基本上我正在研究表格中的项目已经出现了课程ID,并且在这些课程中会出现id学生名称。你可以看到这个图像

enter image description here

数据是获取但无法完美放置。谁能帮我??

<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
);

多数民众赞成我的查询获取数据。

php html codeigniter bootstrap-4
2个回答
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>

循环必须在qazxsw poi内部才能获得同一行的输出


0
投票

只是迭代表格单元格(td),如果行...

<tr>
© www.soinside.com 2019 - 2024. All rights reserved.