如何检索在codeigniter中弹出的bootstrap模式中显示的数据

时间:2016-11-28 13:55:35

标签: codeigniter bootstrap-modal

我正在尝试从数据库中获取产品详细信息并以bootstrap模式显示。请有人帮帮我 查看页面

<table id="myTable" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
<thead>
<tr>
<th>ID</th>
<th>name</th>
<th>Email Address</th>
</tr>
</thead>
<tbody>
<?php foreach ($get_data as $row) : ?>
<tr>
<td><?php echo $row-> id; ?></td>
<td><?php echo $row-> name; ?></td>
<td><?php echo $row-> email; ?></td>
</tr>
<td>
<?php edited(base_url('Department/retrive_data/'.$row-> id));?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

控制器:我在控制器页面上编写了我的反向代码

public function retrive_data($id=null){           
if($this->Department_m->retrive_data($id)){             
$data= [];          
$data['dept_info'] = 'dept/view';    
$data['dept_data'] = $this->Department_m->retrive_data($id);    
$this->load->view('dashboard_layout',$data);    
}          
else {       
redirect(base_url('department/department'));        
}        
}    

模型:我在模型页面上编写了我的反向代码

public function retrive_data($id){    
$query = $this->db->get_where('tbl_dept', array('id' => $id));    
if ($query->num_rows()==1) {    
return $query->result();    
}    
else {    
return FALSE;    
}   
}    

Bootstrap模式视图:我使用的是相同的视图页面。但是无法显示检索数据。怎么解决?请帮帮我....

<div class="modal fade" id="dept_Update" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Basic Informetion</h4>
</div>
<?php if(isset($dept_data)){?>
<div class="modal-body">
<table class="table dt-responsive zero-border">
<tbody>
<input type="text" name="dept_code" id="dept_code" class="form-control" value="<?php echo $dept_data-> id; ?>"/>
</tbody>
</table>
</div>

<div class="modal-footer">
<button type="submit" class="btn btn-default">Update</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
<?php } ?>
</div>
</div>

1 个答案:

答案 0 :(得分:0)

我认为你必须使用Ajax。 请看这里几乎相似的帖子 Codeigniter - Bootstrap Modal - passing data