customer table enter image description here
siteproducts table enter image description here
I want to display the records of currently logged in users product deatils
ex: customer no 15 is logged in then records should displayed only of him
Model
public function customerparcelstatus()
{
$this->db->select('*');
$this->db->from('siteproducts');
$this->db->join('customer', 'siteproducts.customer_id=customer.customer_id');
//$this->db->order_by('customer.customer_id');
return $this->db->get()->result_array();
}
Controller
public function custparcelstatus()
{
$this->load->model('orbitcustomer_model');
$data['parcellistview'] = $this->orbitcustomer_model->customerparcelstatus();
$this->load->view('customer/customer_dashboard', $data);
}
view
<tbody>
<?php if (!empty($parcellistview)) { foreach($parcellistview as $user) {?>
<tr>
<td><?php echo $user['customer_id']; ?></td>
<td><?php echo $user['customer_code']; ?></td>
<td><?php echo $user['product_code']; ?></td>
<td><?php echo $user['received_date']; ?></td>
<td><?php echo $user['received_from']; ?></td>
<td><?php echo $user['tracking_ref_no']; ?></td>
<td><?php echo $user['parcel_status']; ?></td>
<td><?php echo $user['parcel_note']; ?></td>
</tr>
<?php } } else { ?>
<tr>
<td>Norecords Found</td>
</tr>
<?php } ?>
You need to retrieve records only related to currently logged in customer by using where clause on query like below.
$this->db->where('customer_id', $customer); //currently logged in user