Welcome Guest, Not a member yet? Register   Sign In
editing forms
#1

[eluser]the_unforgiven[/eluser]
Hi All,

Im wanting to grab data from the data base in order to edit but i cant seem to get it working so here are my 3 files:

Controller
Code:
// Edit Client List
function editclient()
{
  $data['title'] = 'Edit Client';
  $data['query'] = $this->client_model->edit_client();
  
  $data['Title']['value'] = $query['Title'];
  $data['FullName']['value'] = $query['FullName'];
  $data['FirstName']['value'] = $query['FirstName'];
  $data['LastName']['value'] = $query['LastName'];
  $data['Location']['value'] = $query['Location'];
  
  $this->load->view('editclient', $data);
}

Model
Code:
function edit_client()
{
  $data = array(
       'Title'=>$this->input->get('Title'),
    'FirstName'=>$this->input->post('FirstName'),
       'LastName'=>$this->input->post('LastName'),
    'Location'=>$this->input->post('Location')
  );
  $this->db->where('id', $this->uri->segment(3));
  $this->db->update('tblClientList',$data);
}

View
Code:
<?php
     $attributes = array('class' => 'email', 'id' => 'loginform');
     echo form_open('admin/editclient', $attributes); ?>
     <?php echo form_hidden('id', $this->uri->segment(3));?>
    
    <ul>
     <li><label>Title:</label>&lt;?php echo form_input('Title', $Title); ?&gt;</li>
     <li><label>Full Name:</label>&lt;?php echo form_input('FullName'); ?&gt;</li>
     <li><label>First name:</label>&lt;?php echo form_input('FirstName'); ?&gt;</li>
     <li><label>Last Name:</label>&lt;?php echo form_input('LastName'); ?&gt;</li>
     <li><label>Location:</label>&lt;?php echo form_input('Location'); ?&gt;</li>
    </ul>
    
    &lt;?php echo form_submit('submit', 'Edit Client'); ?&gt;

    &lt;?php echo form_close();?&gt;

Help and code to see where i'm going wrong is much appreciated, thanks a million in advance!
Smile




Theme © iAndrew 2016 - Forum software by © MyBB