Click to display record for specific user in popup

By | August 20, 2018
Questions:

I am using CodeIgniter, I am displaying all the list in the table like below example.

 Id  |Name | Email        | Mobileno | Action
  1  |ABC  | abc@gmail.com|1654789523| View Archive
  2  |xyz  | xyz@gmail.com|3214569874| View Archive

Now When I am clicking on the view button of id 1 then the popup will display with all the information but my issue is, I am getting only the last user id value in the popup. I mean it’s displaying only the records of Id 2.

list code

        <tbody>
   <?php  $n=1;
           foreach ($cust_personal as $row)  
           {  ?>
            <tr>
            <td><?php echo $n;?></td>
            <td><?php echo $row->id;?></td>
            <td><?php echo $row->name;?></td>
            <td><?php echo $row->email;?></td>    
            <td><?php echo $row->mobileno;?></td>
            <td>
            <a  href="javascript:void(0)" onclick="view(this)" data-id="<?=$row->id;?>"> <span>View</span></a>
            <a  href="javascript:void(0)" onclick="archive(this)" data-id="<?=$row->id;?>"> <span>archive</span></a>
            </td> 
        </tr>
<?php $n++;}?>

    </tbody>

popup code

<div class="profile" id="profile-<?=$row->id;?>" style="display: none;">
//details list

</div>

js

function view(obj) 
{
    var id = $(obj).data('id');
    $("#profile-"+id).show();  
}
Answers:
Category: php

Leave a Reply

Your email address will not be published. Required fields are marked *