【发布时间】:2018-05-17 11:41:23
【问题描述】:
我正在尝试使用 href 删除特定记录。但是当我单击按钮时它无法正常工作,它像这样传递 URL
http://localhost/project_x/Organisation/Organisation/%3C?php%20echo%20base_url();?%3EOrganisation/delete_org?id=3
我不知道错误在哪里任何人都可以帮助我。它在 URL 中传递 id 是正确的。
这是我的控制器:
function delete_org() {
// Pass the $id to the org_delete() method
$this->Org_model->org_delete($id);
redirect('Organisation/organisation');
}
这是我的重定向组织功能
public function organisation() {
$data['organisations'] = $this->Org_model->getOrganisations();
$this->load->view('template/header');
$this->load->view("organisation", $data);
$this->load->view('template/footer');
}
这是我的模型:
function org_delete($id) {
$this->db->where('id', $id);
$this->db->delete('organisation');
}
这是我的视图按钮:
<?php
echo "<td class='text-center'><div class='btn-group btn-group-xs'><a href='#' data-logid='" . $org->id . "' data-target='#editGroups' data-toggle='modal' title='Edit' class='open_modal btn btn-default'><i class='fas fa-edit'></i></a>";
echo "<a href='<?php echo base_url();?>/Organisation/delete_org?id=$org->id' class='btn btn-danger confirmation'><i class='fas fa-times'></i></a></div></td></tr>";
?>
谁能帮我解决我做错的地方。
提前致谢。
【问题讨论】:
-
在您的
delete_org中,$id应该来自哪里?它没有定义
标签: php codeigniter url