0
<table class="table admin-table list-table nurserytwo-table">
<thead>
<tr>
<td>ID</td>
<td>Name</td>
<td>Code</td>
<td>Active</td>
<td>Edit</td>
</tr>
</thead>
<tbody>
<?php foreach($nurseries->result() as $nursery) { ?>
<tr>
<td><?php echo $nursery->id; ?></td>
<td><?php echo $nursery->name; ?></td>
<td><?php echo $nursery->code; ?></td>
<td><?php echo set_bool($nursery->active); ?></td>
<td><span class="glyphicon glyphicon-edit"></span> <?php echo
anchor('admin/nurseries/edit_nursery/'.$nursery->id, 'Edit', 'class="edit-
link"'); ?></td>
</tr>
<?php } ?>
</tbody>
</table>
這是我目前的表代碼,我有一個很好的看看,看看我是否可以解決如何做到這一點但我對PHP真的很陌生,看起來似乎無法理解它。我需要在編輯之後添加一個刪除按鈕,我知道我可以通過delete.php來完成,但不知道從哪裏開始。任何幫助將非常感激。需要添加一個刪除按鈕到一個HTML表格從數據庫中刪除記錄與消息
更新:
這是我目前:
}elseif($action == "delete_nursery_course"){
if($id) {
$q = $this->db->where('id', $id)->delete('nursery_courses');
if($this->db->affected_rows() > 0) {
if($this->input->is_ajax_request()) {
$this->output->enable_profiler(FALSE);
echo "SUCCESS"; die();
}else{
set_flash_message('Nursery deleted successfully.',
'success');
}
}else{
if($this->input->is_ajax_request()) {
$this->output->enable_profiler(FALSE);
echo "Something went wrong. Please try again."; die();
}else{
set_flash_message('Something went wrong. Please try
again.', 'error');
}
}
這裏是HTML:
<table class="table admin-table list-table nurseryone-table">
<thead>
<tr>
<td>ID</td>
<td>Name</td>
<td>Colour</td>
<td>Active</td>
<td>Edit</td>
<td>Delete</td>
</tr>
</thead>
<tbody>
<?php foreach($nursery_courses->result() as $nursery_course) { ?>
<tr>
<td><?php echo $nursery_course->id; ?></td>
<td><?php echo $nursery_course->name; ?></td>
<td><div style="background:<?php echo $nursery_course->colour; ?>"
class="course-colour"></div></td>
<td><?php echo set_bool($nursery_course->active); ?></td>
<td><span class="glyphicon glyphicon-edit"></span> <?php echo
anchor('admin/nurseries/edit_nursery_course/'.$nursery_course->id, Edit', 'class="edit-link"'); ?></td>
<td>
<span class="glyphicon glyphicon-trash"></span> <?php echo
anchor('admin/nurseries/delete_nursery_course/'.$nursery_course->id,
'delete', 'class="delete-link"'); ?></td>
</tr>
<?php } ?>
</tbody>
</table>
是你的編輯鏈接的工作? –
這是耶。你想讓我發佈代碼嗎? – mischiefbec
是的,這可能會有所幫助。 –