I have two tables one is 'student' another is 'status'.The student table has a foreign key status_status_id. I want to update this status_status_field. In my view the all the status (junior, senior, fresher, sophomore) from the status are shown in a drop down menu.
I want to update the status_status_id (initially it has the value 0) field of student table by taking inputs from this drop down. And to update i also need the id of a particular student. The problem is the field status_status_id is not updating. The following error is showing-
A Database Error Occurred
Error Number: 1054
Unknown column 'Array' in 'where clause'
UPDATE `student` SET `0` = '' WHERE `id` = Array
Filename: Z:\www\CI\system\database\DB_driver.php
Line Number: 330
my controller
public function update()
{
$id = $this->input->post('id');
$data = array(
'status_status_id' => $this->input->post('status_status_id'),
);
$this->status_model->update($data, $id);
}
my model
public function update($data, $id)
{
$this->db->where('id', $id);
$this->db->update('student', $data);
}
View for adding a status
<?php echo form_open('status_controller/update');
$r = $info[0]->id;
$data = array (
'id' => $r,
'status_status_id' => set_value('status_status_id')
);
?>
<p><?php echo form_input($data); ?>
<p><select name ='status_status_id'>
<?php echo form_error('status_status_id'); ?>
<br /><?php
$getType = mysql_query("SELECT status_id, status FROM status ORDER BY status_id");
while ($type = mysql_fetch_object($getType)) {
echo "<option value=\"{$type->status_id}\">{$type->status} </option>", set_value('status_status_id');
}
?>
</p>
<p><?php echo form_submit('submit', 'Update Status'); ?></p>
<?php echo form_close(); ?>