CodeIgniter Forums
how to create the detail for every row of the table - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: how to create the detail for every row of the table (/showthread.php?tid=18096)



how to create the detail for every row of the table - El Forum - 04-25-2009

[eluser]Unknown[/eluser]
hi all..
i was created a table 'member' with 5 fields,,ID, name, address, gender and email,,,
and in the member page i was show the table but just for ID and name field,,,
Code:
<?php
$data = $this->db->get('member');
foreach ($data as $row)
{
?>
<tr>
<td> &lt;?php echo $row->ID; ?&gt; </td>
<td> &lt;?php echo $row->name; ?&gt; </td>
<td> &lt;?php echo $row->name; ?&gt; </td>
&lt;?php echo anchor('member/memberdetail/','detail'); ?&gt;
</tr>
&lt;?php
}
?&gt;

and the result of every row was show with 'detail' link,,end this is link for the detail of the row,,but i don't know to make the detail page to show the complete data of the specific member,,
please help me to build it...


how to create the detail for every row of the table - El Forum - 04-25-2009

[eluser]Dam1an[/eluser]
I would make the link be
Code:
&lt;?=anchor('member/details/'.$row->ID, 'Details')?&gt;
That will include the members ID in the URL, such as member/details/123

In the member controller, add something like this
Code:
function details($id) {
  // This should really be done in a model, but is here for simplicity sake
  $this->db->where('id', $id);
  $user = $this->db->get('members')->row();
  
  // Either create veriables for each member attribute, or pass the user object to your view, and display everything in the way of your choosing
}

Make sense?