0

so i've been trying to do this multiple times but stil didnt get the answer. i have a column named closed in my database and close button in my view, whenever i click the button close, i want it to update my closed column to '0' if it is closed and '1' if it still open. below is my code in controller, sorry im still new to this.

Public function close(){

      $pvar = array();
      $pid = $this->uri->segment(1, 0);
      $iid = $this->uri->segment(2, 0);
      $pageisx = $this->uri->segment(3, 0);
      $pagei = 'Purchase Order';
      $iuser = $this->users->chkadmin();
      $gpost = $this->input->post(NULL, TRUE);
      $pvar['pageimenu'] = 'purchasing';
      $pvar['htitle'] = 'Purchase: '.$iid;

      $this->db->select('*');
      $this->db->from('po');
      $this->db->where('po.pono', $iid);
      $this->db->order_by('po.pono', 'DESC');

      $pvar['purchaseorder'] = $this->db->get()->row_array();

      if (isset($gpost['close']))
      {
        if (isset($gpost['locode'])) {
          $getlo = $gpost['locode'];
          if ($getlo == $this->session->skey) {
            foreach ($gpost['close'] as $k => $x) {

              $close = 1;
              $c['closed'] = $close;

              //$close = $this->input->post('1');

                $this->db->set('closed', 1 );
                $this->db->where('po.id', $k);
                $this->db->update('po');
              }

        redirect(base_url().'purchaseorderlist.php');
      }}}

        $pvar['css'] = '
        <link href="'.base_url().'css/manage.css" rel="stylesheet" type="text/css" />
      ';
      $pvar['pc'] = $this->load->view('purchasing/purchaseorderview', $pvar, TRUE);
      $this->load->view('home', $pvar);
      }

i use codeigniter btw....thanks

Edited by kayla_95

1
Contributor
0
Replies
18
Views
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.