【发布时间】:2020-02-01 20:32:27
【问题描述】:
我在这个项目中使用 CodeIgniter。在“v_pembayaran_admin”页面上,我有一个名为“pembayaran”的表,它必须显示一个名为“nama_user”的列。 “nama_user”列从“pendaftar”表中获取数据,但通过“user”表获取数据。因此,“pendaftar”表中的“nama_user”列只有在“user”表中已经存在时才会出现在“pembayaran”表中。我已经尝试了一些方法,但找不到我想要的最终结果,并且出现错误。请帮我尽快解决。 。 。链是“pembayaran”->“user”->“pendaftar。
Pembayaran 的控制器:
public function index()
{
$this->load->model('pembayaran_m');
$data['data_pembayaran']=$this->pembayaran_m->get_pembayaran();
$this->load->model('user_m');
$data['data_user']=$this->user_m->get_user();
$this->load->model('pertemuan_m');
$data['data_pertemuan']=$this->pertemuan_m->get_pertemuan();
$this->load->view('v_pembayaran_admin', $data);
$this->load->view('template');
}
Pembayaran 的模型:
public function get_pembayaran()
{
$data_pembayaran = $this->db
->join('user','user.id_user=pembayaran.id_user')
->join('pertemuan','pertemuan.id_pertemuan=pembayaran.id_pertemuan')
->get('pembayaran')
->result_array();
return $data_pembayaran;
}
public function masuk_db()
{
$data_pembayaran=array(
'tgl_bayar'=>$this->input->post('tgl_bayar'),
'id_user'=>$this->input->post('id_user'),
'id_pertemuan'=>$this->input->post('id_pertemuan'),
'uang_kursus'=>$this->input->post('uang_kursus'),
'uang_daftar'=>$this->input->post('uang_daftar'),
'total'=>$this->input->post('total'),
'via'=>$this->input->post('via'),
'ket'=>$this->input->post('ket')
);
$sql_masuk=$this->db->insert('pembayaran', $data_pembayaran);
return $sql_masuk;
}
彭巴亚兰的观点:
<table class="table table-hover table-striped">
<tr>
<th>NO</th>
<th>TANGGAL BAYAR</th>
<th>NAMA SISWA</th>
<th>TOTAL PERTEMUAN</th>
<th>UANG KURSUS</th>
<th>UANG PENDAFTARAN</th>
<th>TOTAL TAGIHAN</th>
<th>VIA</th>
<th>KETERANGAN</th>
<th>AKSI</th>
</tr>
<?php
$no=0;
foreach ($data_pembayaran as $byr) {
$no++;
echo '<tr>
<td>'.$no.'</td>
<td>'.$byr['tgl_bayar'].'</td>
<td>'.$byr['nama_user'].'</td>
<td>'.$byr['pertemuan'].'</td>
<td>Rp '.$byr['uang_kursus'].'</td>
<td>Rp '.$byr['uang_daftar'].'</td>
<td>Rp '.$byr['total'].'</td>
<td>'.$byr['via'].'</td>
<td>'.$byr['ket'].'</td>
<td><a href="#update_pembayaran" class="btn btn-warning" data-toggle="modal"
onclick="tm_detail('.$byr['id_pembayaran'].')">Update</a>
<a href="'.base_url('index.php/Pembayaran/hapus_pembayaran/'.$byr['id_pembayaran']).'"
class="btn btn-danger" onclick="return confirm(\'Yakin Hapus?\')">Delete</a></td>
</tr>';
}
?>
</table>
请帮帮我..
【问题讨论】:
-
你没有分享
pertemuan_m模型需要检查这个方法get_pertemuan
标签: php mysql bootstrap-4 phpmyadmin codeigniter-3