hi, i just learned this codeigniter in my college.
I have a confusion to display the last row data from the table that has been joined in the model.
I tried the code below but the error is due to Std Class. is there a neater syntax? or is it better for my problem ?
below my MVC :
Controller :
Code:
public function result_last_request($where)
{
return $this->db->query(
"SELECT * FROM request_order bo, user d,detail_request bu WHERE bu.kode_order=bo.kode_ro AND d.id_user=bo.id_user='$where'"
)->last_row();
}
Model :
Code:
public function result_request()
{
$where = $this->session->userdata('id_user');
$data = [
'title' => 'Finish Order',
'nama' => $this->session->userdata('nama'),
'user' => $this->userModel->get_user_session(),
'request' => $this->requestModel->result_last_request($where)
];
$this->load->view('homepage/layouts/header', $data);
$this->load->view('homepage/layouts/sidebar', $data);
$this->load->view('homepage/layouts/topbar', $data);
$this->load->view('requestorder/fin_info_request', $data);
$this->load->view('homepage/layouts/footer', $data);
}
View
Code:
<tbody align=center>
<?php $no = 0;
foreach ($request as $row) :
$no++;
?>
<tr>
<td><?= $no ?></td>
<td><?= $row['kode_order']; ?></td>
<td><?= $row['jenis_barang'] ?></td>
<td><?= $row['desk_barang'] ?></td>
<td><?= $row['qty_order'] ?></td>
<td><?= $row['sat_order'] ?></td>
<td><img src="<?= base_url(); ?>assets/img/foto-order/<?= $row['img_order']; ?>" style="max-width:100%; max-height: 100%; height: 100px; width: 80px"></td>
</tr>
<?php endforeach; ?>
</tbody>
thanks if anybody can help me