I would like to get the ID of a value from a database and use it to delete an item.
Heres my code:
This code currently gets a set of records from a database, where each record has links. How can I do this?
<h2>List of all polls in this site:</h2>
<?php echo '<table>';?>
<table border="1">
<tr>
<th>Title</th>
<th>Text</th>
<th colspan="2">Action</th>
</tr>
<?php
foreach($polls as $polls_item){
echo "<tr>";
echo "<td>". $polls_item['title'] ."</td>";
echo "<td>". $polls_item['text'] ."</td>";
echo "<td>". anchor('user/vote/'.$polls_item->id,'Vote') ."</td>";
echo "<td>". anchor('admin/del/'.$polls_item->id,'Delete') ."</td>";
echo "</tr>";
}
?>
<?php echo anchor('admin/del/1','Delete'); ?>
</table>
I will assume that you have an admin controller, and you loaded admin_model at the beginning which is where you get all your polls
Then in your admin_model where polls is the table name of your database
I hope this is clear enough.