⚠ 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

one click update



DREON

DREON
  • profile picture
  • Member

Posted 03 May 2013 - 04:33 AM

hi masters, i have a table with fiedds

 

officeCode |    name | action (Bolean 0/1)

 

and i create an

 

$crud->add_action('Send', '', 'examples/sendrows', 'ui-icon-plus');

 

 

 

function sendrows($id) {
                $this->db->where('officeCode',$id);
                $rs = $this->db->get('offices')->row_array();
         
                $data['action'] = '1';

      
            $this->db->update('offices',$data);
            redirect('examples/offices_management');
    
        }

 

how can i update only a selected row when i click the Send button on my GC list..

 

on my code above when i click Send it will update all my action field data from offices.. all i want is to update only the selected row.


victor

victor
  • profile picture
  • Member

Posted 03 May 2013 - 06:39 AM

$this->db->update('offices',$data,array(id=> your-id));
read documentation how to update a row.

DREON

DREON
  • profile picture
  • Member

Posted 03 May 2013 - 14:12 PM

got it.. thank you sir victor.. 

 

another sir, how can i redirect to this url:

 

after i click Send button.

 

http://localhost/grocery_crud/index.php/examples/offices_management/edit/2


DREON

DREON
  • profile picture
  • Member

Posted 06 May 2013 - 00:41 AM

got it..


           redirect(site_url('admin/main/view_support_longleave/'.$id));


vladbutterfly

vladbutterfly
  • profile picture
  • Member

Posted 06 May 2013 - 10:16 AM

Hi Dreon

could you please post the controller code for this redirect function with the sql dump

thx


DREON

DREON
  • profile picture
  • Member

Posted 06 May 2013 - 22:40 PM

this redirect is for add action one click update:

 

my add action sample:

 

$crud->add_action('Inactive', '', 'admin/main/inactive_support','ui-icon-plus');

 

 

function inactive_support($id) {
    
            $data['status'] = 'inactive';
            $this->db->update('support_list',$data,array(id=>$id));
            redirect(site_url('admin/main/view_support_longleave/'.$id.'/add'));
            }

 

after i click that Inactive button i will redirect to view_support_long leave add field view.

 

my sample dump sql:

id(this id is my primary id) |   leave_applied  |  from |   | to