mercredi 22 janvier 2020

I get Undefined offset: 70 When i try to submit foreach loop into database

I have the following foreach in my view that i am trying to submit it into my database..without any luck...when i try to submit using the code from my controller is returns an error Undefined offset: 70

//This is the controller code


 $ammt = $request->amount;

          foreach ($request->userid as $key => $value){



               $answer = new Retirement();
            $answer->user_id = $value;
               $answer->amount =  $ammt[$key];


               $answer-> save();


          }



//This is my view file with the foreach loop
     @foreach ($request as $item)
                            <tbody>
                              <tr>
                              <td  class="idweek1"> <input type="text" id="userid" name="userid" class="form-control" value=""> </td>
                              <td><input type="text" id="marketers" name="marketers[]" class="form-control" value="">  </td>
                              <td><input type="text" id="amount" name="amount[]" class="form-control" value=""> </td>
                              <!-- <td></td> -->
                              <td><input type="text" id="mar1id" class="form-control" value="">   </td> 
                              </tr>
                            </tbody>

                            @endforeach


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire