How to get id of a CRUD element [CodeIgniter]

0

My question is this: I have a CRUD made in CodeIgniter , but the table rows are not in the localhost/crud/produtos/[:num] format.

In the last column of the table you have action buttons to edit and remove, one for each row. How can I get the controller the id of the line where the button is loaded?

I put input type hidden the value of the id, and got it in the controller by method post . Is there another more agile method to do?

<?php foreach($query as $row): ?>
    <tr>
        <th><?php echo $row->id; ?></th>
        <td><?php echo $row->autocarro; ?></td>
        <td><?php echo date("d-m-Y", strtotime($row->validade)); ?></td>
        <td>
            <form method="post" type="submit" action="<?php echo base_url('sistema/edit_extintores'); ?>" style="padding-right: 4px;"> 
                <input name="id_ext" type="hidden" value="<?php echo $row->id; ?>">
                <button type="submit"><i class="fa fa-pencil"></i></button>          
            </form>
            <form method="post" type="submit" action="<?php echo base_url('#'); ?>"> 
                <input name="id_ext" type="hidden" value="<?php echo $row->id; ?>">
                <button type="submit"><i class="fa fa-trash"></i></button>          
            </form>
        </td>
    </tr>
<?php endforeach; ?>

The data is taken from the DB table, and I want to click on the button as an indication in the image, get the id of that line to get all the information related to that id of the database.

    
asked by anonymous 05.03.2018 / 20:50

1 answer

-1

Use $row['id']

While you are inside your block foreach you can get this data.

    
22.03.2018 / 19:38