Welcome Guest, Not a member yet? Register   Sign In
how to create the detail for every row of the table
#1

[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...
#2

[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?




Theme © iAndrew 2016 - Forum software by © MyBB