⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Execute update per row



SiyaStoan
  • profile picture
  • Member

Posted 15 February 2013 - 05:41 AM

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


victor
  • profile picture
  • Member

Posted 16 February 2013 - 08:42 AM

/topic/1341-add-quick-update-button-in-view-1-0-value/#entry5690