我想从数据库中获取一个值的 ID 并用它来删除一个项目。这是我的代码:
此代码当前从数据库中获取一组记录,其中每条记录都有链接。我怎样才能做到这一点?
<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>