我开发了一个程序,其中一个功能是,如果你打勾“是”'在单选按钮中,整行将显示在下一页中。
问题是,我试图在我的数据库中插入单选按钮值,但数据库需要我的表的整个值,我已经在我的原始数据库中(我只想将单选按钮值插入到列中) )。
这是我的代码
控制器:
public function verify()
{
$password2 = $this->input->post('password2');
log_message('error','isi password : '.$password2);
$return = $this->welcome_model->checkPassword($password2);
$data=$this->welcome_model;
$data->verif=$this->input->post("rad$id");
$data->insert_radio($id);
if($return){
redirect('welcome/success');
}
else{
redirect('welcome/masuk');
}
}
型号:
public function insert_radio($id){
$data=(array)$this;
$this->db->insert("info",$data);
}
查看:
<div class="radio">
<label>
<input type="radio" name="rad[<?php echo $row->id;?>]"/>
Yes
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rad[<?php echo $row->id;?>]"/>
No
</label>
</div>
</div>
任何帮助将不胜感激!
答案 0 :(得分:0)
如果要更新已具有值的表,请使用以下
$this->db
->set('name', 'value')
->set('name', 'value')
->where('condition_name', 'condtion_value')
->update()
如果您对HTML有任何疑问,可以使用以下
而不是
<input type="radio" name="rad[<?php echo $row->id;?>]"/>
使用以下方式
<input type="radio" name="radio_name" value="rad[<?php echo $row->id;?>]"/>