以特定格式显示表格中的数据

时间:2017-11-22 16:06:29

标签: php codeigniter

我想以我附加的特定格式显示数据。教师添加的每个对象,标题和坐标应显示在一行教师面前。这就是我想要的enter image description here。这就是我目前获取数据的方式enter image description here

视图和控制器的代码在这里

    <table id="example2" class="table table-bordered table-hover">
        <thead>
            <tr>
              <th>#</th>
              <th>Instructor</th>
              <th>Title</th>
              <th>Coordinates</th>
              <th>Actions</th>
            </tr>
          </thead>

          <tbody>
            <?php $i=1; foreach ($res as  $value) { ?>
            <tr>
              <td><?php echo $i++; ?></td>                           
              <td><?php echo $value['first_name'] . " " . $value['last_name']; ?></td>
              <td><?php echo $value['description']; ?></td>
              <td><?php echo $value['coordinates']; ?></td>   

              <td>
                <?php if($edit_delete['edit']) {?>
                <a href="<?php echo $base_url; ?>Objects/view/<?php echo $value['id']; ?>"><i class="fa fa-eye"></i></a> 
                <?php }  ?>
              </td>

            </tr>
            <?php } ?>
          </tbody>
    </table>

public function index()
    {
        $this->user_model->check_permissions('Objects/index');
        $data['edit_delete']=$this->user_model->checkEditDelete('Objects/index');

        $rl_id= $this->rol_id;
        $str = implode('-',$rl_id);

        if($str==2)
        {
            $data['menu']=$this->load_model->menu_inst();
        }else
        {
            $data['menu']=$this->load_model->menu();
        }
            $data['base_url'] = base_url();
            $data['userInfo'] = $this->userInfo;
            $rl_id= $this->rol_id;
            $super = implode('-',$rl_id);
        if($super==1)
        {
         $this->db->select('object.id, object.description, object.coordinates, admin.first_name, admin.last_name');
        $this->db->from('object');
        $this->db->join('admin', 'admin.id = object.instructor_id');
        $this->db->where('admin.is_delete',0);
        $this->db->where('admin.role_id',2);
        $this->db->where('object.is_delete',0);
        $data['res'] = $this->db->get()->result_array();
        }
        else
        {
        $in_id= $this->insret_id;
        $insrtuctur = implode('-',$in_id);
        $data['data'] = $this->db->where('is_delete',0)->where('instructor_id',$insrtuctur)->get('object')->result_array();
        }

        $data['page'] = "objects/objects";
        $this->load->view('Template/main', $data);
}

0 个答案:

没有答案