Php can';t使用href删除codeigniter中的记录
我正在尝试使用href删除特定记录。但当我点击按钮时,它不能正常工作,它会像这样传入URLPhp can';t使用href删除codeigniter中的记录,php,codeigniter,url,Php,Codeigniter,Url,我正在尝试使用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 t
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>";
?>
问题是您正在echo中再次添加php标记。更改删除锚标记,如下所示:
echo "<a href='".base_url()."/Organisation/delete_org?id=$org->id' class='btn btn-danger confirmation'><i class='fas fa-times'></i></a></div></td></tr>";
问题是您正在echo中再次添加php标记。更改删除锚标记,如下所示:
echo "<a href='".base_url()."/Organisation/delete_org?id=$org->id' class='btn btn-danger confirmation'><i class='fas fa-times'></i></a></div></td></tr>";
希望这对您有所帮助:
更改视图按钮,如下所示:
<?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='".base_url('Organisation/delete_org?id='.$org->id)."' class='btn btn-danger confirmation'><i class='fas fa-times'></i></a></div></td></tr>";
希望这对您有所帮助:
更改视图按钮,如下所示:
<?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='".base_url('Organisation/delete_org?id='.$org->id)."' class='btn btn-danger confirmation'><i class='fas fa-times'></i></a></div></td></tr>";
您可以尝试使用codeigniter framework按数据属性删除记录,如下所示
html
<a class="deletedata" data-id="<?php echo $data['id] ?>">delete</a>
这里我的控制器名称是Products。你可以定义你的名字和名字
而不是在定义方法名称之后
控制器
public function dltProduct($id) {
$this->db->where("id",$id);
$this->db->delete("tbl_name");
}
您可以尝试使用codeigniter framework按数据属性删除记录,如下所示
html
<a class="deletedata" data-id="<?php echo $data['id] ?>">delete</a>
这里我的控制器名称是Products。你可以定义你的名字和名字
而不是在定义方法名称之后
控制器
public function dltProduct($id) {
$this->db->where("id",$id);
$this->db->delete("tbl_name");
}
在您的delete_org
中,$id
应该来自哪里?您的delete\u org
中没有定义,$id
应该从哪里来?它没有定义