Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter无法正确更改我的sql表_Php_Html_Codeigniter - Fatal编程技术网

Php CodeIgniter无法正确更改我的sql表

Php CodeIgniter无法正确更改我的sql表,php,html,codeigniter,Php,Html,Codeigniter,我需要在我的sql中更改一个字符串,脚本可以正常工作,但不会执行任何操作。我试图输入要更改的行的ID,然后输入如何更改该行变量的条件。这是我的密码 控制器: public function admin(){ $this->load->model('model_users'); $data2['users'] = $this->model_users->change_condition(); $this->load->view("content_admin",

我需要在我的sql中更改一个字符串,脚本可以正常工作,但不会执行任何操作。我试图输入要更改的行的ID,然后输入如何更改该行变量的条件。这是我的密码

控制器:

public function admin(){
$this->load->model('model_users');
$data2['users'] = $this->model_users->change_condition();
$this->load->view("content_admin", $data2);
}
型号:

public function change_condition() {
$data = array(
    'order_condition' => $this->input->post('order_condition')
    );
$where = array(
    'ID' => $this->input->post('ID')
        );
$str = $this->db->update_string('users', $data, $where);
}
视图:

您应该使用$this->db->update而不是$this->db->update\u字符串,并在$this->db->where中传递$where数组:


代码工作得很完美,但现在我有一个问题,我不知道它为什么会发生。所以,我使用您的代码在db中添加项,但我需要两个这样的代码,所以另一个我称之为change_condition2。因此,这两个代码都可以工作,将项目添加到我的数据库中,但现在当我更改change_条件时,同一行中的change_条件2变为等于数字0。当我改变条件时,一切都很好。我不知道为什么会这样。我试图通过MSQL在db中手动添加项,一切正常,所以这不是db的错误。也许你能帮我解决这个问题。
<form name="contactform" method="POST" action="<?php echo base_url();?>site/change">
<td valign="top">
ID
</td>
<input  type="text" name="ID" maxlength="20" size="30">
<td valign="top">
Order Condition
</td>
<input  type="text" name="order_condition" maxlength="80" size="30">
<input type="submit" value="Change" name="submit" />
</form>
public function change_condition() {
    $data = array(
        'email' => $this->input->post('email')
    );
    $where = array(
        'ID' => $this->input->post('ID')
    );
    $this->db->where($where);
    $str = $this->db->update('users', $data);
    return $str;
}