I have a list of clients and on click of each client i wish to display details of that particular client only, for this i used the following code.
The view of client list is something like this
id fullname
1 A
2 B
3 C
When i click on A i get redirected to other page whose url is http://localhost/projname/admin/client/1
When i click on B i get redirected to other page whose url is http://localhost/projname/admin/client/2
And so on.... the id keeps on changing depending on the click
But the issue is that when i try to display the data in client_detail_view.php page i get the data of first id only i.e id=1
Structure of codeigniter is
controllers
-admin.php
model
-admin_model.php
views
-admin
-client_view.php
-client_detail_view.php
Code for admin.php
public function client($clientid)
{
$data['client_data'] = $this->admin_model->get_client($clientid);
$this->load->view('admin/client_detail_view',$data);
}
Code for admin_model.php
public function get_client($id)
{
$query = $this->db->get('users');
$this->db->where('id', $id);
return $query->row();
}
Code for client_view.php
<?php foreach($client as $perclient): ?>
<tr>
<?php echo "<td><a href='". base_url() ."admin/client/".$perclient->id."'>" . $perclient->fullname . "</a></td>"; ?>
<td><?php echo $perclient->email; ?></td>
<td><?php echo $perclient->contactno; ?></td>
</tr>
<?php endforeach; ?>
Code for client_detail_view.php
<?php echo $client_data->fullname; ?>