|
楼主 |
发表于 2010-2-21 17:48:21
|
显示全部楼层
回复 2# Hex
麻烦了!谢谢HEX~
view中:
<hr />
<?php echo form_open('client/modify');//提交到modify作修改?>
<strong>请修改客户资料</strong>
<?php foreach ($get as $row):?>
<p>客户姓名<input type="text" name="name" value="<?=$row->name?>"/></p>
<p>地址input type="text" name="address" value="<?=$row->address?>"/></p>
<p>电子邮箱<input type="text" name="email" value="<?=$row->email?>"/></p>
<p>电话input type="text" name="telephone" value="<?=$row->telephone?>"/></p>
<p>手机<input type="text" name="mobile" value="<?=$row->mobile?>"/></p>
<p>
<input type="submit" name="submit" value="提交" />
<input type="reset" name="submit" value="重置" />
</p>
<?php endforeach;?>
</form>[]
MODEL中:
function get($id) { //获取指定ID的记录,结果读出到修改的表单中
$this->db->select('*')->from('client');
$this->db->where('cli_id',$id);
$query = $this->db->get();
return $query->result();
function modify($id) {//执行修改过程
$fields = array(
'name' => $this->input->post('name'),
'address' => $this->input->post('address'),
'email' => $this->input->post('email'),
'mobile' => $this->input->post('mobile'),
'telephone' => $this->input->post('telephone'),
'date' => date('Y-m-d H:i:s'),
'account' => $this->session->userdata('name')
);
$this->db->where('cli_id', $id);
$this->db->update('client', $fields);
}
C中:
function get() {
$this->load->view('header_view');
$this->load->view('user_view');
$this->load->view('tab_view');//上面三个都是头部信息
$id = $this->uri->segment(3);
$this->load->model('client_model');
$data['get'] = $this->client_model->get($id);
$this->load->view('client/modify_view',$data);
$this->load->view('footer_view'); //尾部信息
}
function modify() {
$id = $this->uri->segment(3);
$this->load->model('client_model');
$this->client_model->modify($id);
redirect('client'); |
|