Php Codeigniter删除链接未出现在我的视图表中
您能检查一下为什么不能删除该行吗。我得到数据库错误:不允许删除,除非它们包含“where”或“like”子句。非常感谢你的帮助 以下是我的看法:Php Codeigniter删除链接未出现在我的视图表中,php,codeigniter,Php,Codeigniter,您能检查一下为什么不能删除该行吗。我得到数据库错误:不允许删除,除非它们包含“where”或“like”子句。非常感谢你的帮助 以下是我的看法: <td><a href="<?php echo base_url("admin/delete_row/".$user['user_id'] ); ?>">Delete</a></td> 这是我的模型: pu
<td><a href="<?php echo base_url("admin/delete_row/".$user['user_id']
); ?>">Delete</a></td>
这是我的模型:
public function did_delete_row(){
$this->db->where('user_id', $this->input->get('user_id'));
$this->db->delete('users');
if ($this->db->delete('users'))
{return true;}
else
{return false;}
}
试试这个:
<td><a href="<?php echo base_url("admin/delete_row/".$user['user_id']); ?>">Delete</a></td>
public function delete_row(){
$id = $this->uri->segment(3)
if ($this->session->userdata('is_admin_logged_in'))
{
$this->load->model("model_admin");
$this->model_admin->did_delete_row($id);
}
else
{
redirect('admin/login');
}
}
public function did_delete_row($id){
if ($this->db->delete('users', array('user_id' => $id)))
{
return true;
}
else
{
return false;
}
}
控制器:
<td><a href="<?php echo base_url("admin/delete_row/".$user['user_id']); ?>">Delete</a></td>
public function delete_row(){
$id = $this->uri->segment(3)
if ($this->session->userdata('is_admin_logged_in'))
{
$this->load->model("model_admin");
$this->model_admin->did_delete_row($id);
}
else
{
redirect('admin/login');
}
}
public function did_delete_row($id){
if ($this->db->delete('users', array('user_id' => $id)))
{
return true;
}
else
{
return false;
}
}
型号:
<td><a href="<?php echo base_url("admin/delete_row/".$user['user_id']); ?>">Delete</a></td>
public function delete_row(){
$id = $this->uri->segment(3)
if ($this->session->userdata('is_admin_logged_in'))
{
$this->load->model("model_admin");
$this->model_admin->did_delete_row($id);
}
else
{
redirect('admin/login');
}
}
public function did_delete_row($id){
if ($this->db->delete('users', array('user_id' => $id)))
{
return true;
}
else
{
return false;
}
}
你可以试试这个
<td>
<a href=<?php echo base_url()."admin/delete_row/".$user['user_id'];?>>Delete</a>
</td>
您的链接未显示或不工作?未显示,但当我删除这部分代码时,它正在显示。尝试用完整路径替换base_url(),可能是您忘记加载url帮助器url帮助器已加载,问题在于加载了这部分代码url帮助器。我按照您描述的方式进行了尝试,但仍然没有显示$user['user_id']的linkcheck值已设置??我刚刚添加了视图代码。你能检查一下$user['user\u id']是否被设置了吗?@TProDeveloper用$user->user\u id替换$user['user\u id'],我做到了。现在链接出现了,但当我点击链接时,它显示错误“不允许删除,除非它们包含“where”或“like”子句。”。你能帮帮我吗。