Help get from view Update multiple row

<form method="post" name="form1">

<input name="check[1]" type="checkbox" value="1"/> <input name="quantity[1]" type="checkbox" value="5"/>

<input name="check[2]" type="checkbox" value="2"/> <input name="quantity[2]" type="checkbox" value="2"/>

<input name="check[3]" type="checkbox" value="3"/> <input name="quantity[3]" type="checkbox" value="8"/>

<input type="submit" name="listupdate" class="btn btn-success" value="Update"> </form>

in controllers

foreach ($_POST['check'] as $value) 

{

code get post update....

}

Help me ! Thanks



2.8k

Post your solution then, you know, to help others and to prevent another 979 case later.

Done



106

Ok, This is my solution

                foreach ($this->request->getPost('check') as $value) 
                  {
                        if(is_numeric($this->request->getPost()['quantity'][$value]))
                        {
                              $valueupdate = $this->request->getPost()['quantity'][$value];
                              $updatelist = Mytable::findFirstById($value);
                              if($updatelist)
                              {
                                  $updatelist->assign(['quantity' => $valueupdate]);
                                  if($updatelist->save())
                                  {
                                    // Complete
                                    return $this->response->redirect('/'); 
                                  } 
                              }
                        }      
                  }

It was working