我正在使用Codeigniter,我正在创建一个函数,该函数使用两个Foreach函数中的2个变量基于表中的值替换文本,以下是我编写的代码示例,但似乎没有
表“声明”和“声明过程”结构
id_claim | artist_name | claim_date | claim_amount | status
模型
//ADMIN_CLAIM
function Tampil_claim_admin(){
return $this->db->get('claim');
}
function Input_claim($data,$table){
$this->db->insert($table,$data);
}
function edit_claim($where,$table){
return $this->db->get_where($table,$where);
}
function update_claim($where,$data,$table){
$this->db->where($where);
$this->db->update($table,$data);
}
function delete_claim($where,$table){
$this->db->where($where);
$this->db->delete($table);
}
//ADMIN_CLAIM_PROCESS
function Tampil_claim_admin_process(){
return $this->db->get('claim_process');
}
function Input_claim_process($data,$table){
$this->db->insert($table,$data);
}
function edit_claim_process($where,$table){
return $this->db->get_where($table,$where);
}
function update_claim_process($where,$data,$table){
$this->db->where($where);
$this->db->update($table,$data);
}
function delete_claim_process($where,$table){
$this->db->where($where);
$this->db->delete($table);
}
控制器
function index(){
$data['claim'] = $this->m_admin_data->Tampil_claim_admin()->result();
$data['claim_process'] = $this->m_admin_data->Tampil_claim_admin_process()->result();
$this->load->view('admin/v_admin_claim',$data);
}
查看
<tr>
<td>MSC-CLAIM- <?php foreach ($claim as $data):
endforeach;
foreach ($claim_process as $data):
endforeach;
echo $data->id_claim; ?></td>
<td><?php echo $data->artist_name; ?></td>
<td><?php echo date('d-m-Y', strtotime($data->claim_date)); ?></td>
<td>$ <?php echo $data->claim_amount; ?></td>
<td><?php if ($data->status = 'On Process') { ?>
<?php echo anchor('Admin_claim/edit_claim_process/' . $data->id_claim, 'Process'); ?>
<?php else { ?>
<span class="label label-primary"> <?php echo "Sudah di Selesai"; ?> </span>
<?php } ?></td>