[eluser]Waqar[/eluser]
Here is my controler
Code:
function add_edit()
{
$data['query']= $this->tpc_model->add_individual();
redirect('individual/index');
}
model
Code:
function add_individual()
{
$data = array(
'title'=>$this->input->post('title'),
'firstname' =>$this->input->post('firstname'),
'surname' =>$this->input->post('surname'),
'initials' =>$this->input->post('initial'),);
if($id = $this->input->post('id'))
{
$where = "id = '$id'";
$query = $this->db->update('individuals', $data, $where);
}
else
{
$query = $this->db->insert('individuals', $data);
}
my view
Code:
$attributes = array('class' => 'indvidual', 'id' => 'individualform');
echo form_open('individual/add',$attributes);?>
<?php form_hidden('id',$id);?>
<label for="title">Title: </label>
<?php $options = array(
'Mr' => 'Mr',
'Mrs' => 'Mrs',
'Ms' => 'Ms',
'Dr' => 'Dr',
'Prof' => 'Prof',
);
echo form_dropdown('title', $options);?><br>
<label for="firstname">First Name: </label>
<input type="text" id="firstname" name="firstname" value="<?=$firstname; ?>"><br>
<label for="surname">Surname: </label>
<input type="text" id="surname" name="surname"><br>
<label for="initial">Initials: </label>
<input type="text" id="initial" name="initial"><br>
<input type="submit" id="go" value="Save">
<?= form_close();?>