Hi Guys
How can I update one row? I want to have a cancel button on the grid, which if the user clicks, it gonna update that particular record only. At the moment it updates all the records on the database. Please help. Please see my two different attempts below.
Attempt 1:
$bookings->add_action('Cancel', '', '', 'ui-icon-image', array($this, 'cancel_booking')); function cancel_booking($primary_key, $row) { $data = array('is_cancelled' => 0); $this->db->where('id', $primary_key); $this->db->update('bookings', $data); return site_url('main/booking_management') . '?id=' . $row->id; }
Attempt 2:
$bookings->callback_column('is_cancelled', array($this, '_callback_webpage_url')); public function _callback_webpage_url($value, $row) { $data = array('is_cancelled' => 0); $this->db->where('id', $row->id); $this->db->update('bookings', $data); $val = 'Cancel'; return "<a href='" . site_url('main/booking_management/' . $row->id) . "'>$val</a>"; }
Thanx