Sunday, March 12, 2017

Put the Requested value in a array or how to add the values in Laravel 5.2

I am trying to create multiple choice question answer page. First a question will be show with three or more multiple choice answers. As the provided Image. Question Page

In the page I have created a form that show the multiple choice answers . if a user click submit button it will pass the answer id(numerical id) with correspond value 0 & 1. where 1 is correct and 0 is wrong.

 <form class="form-horizontal" role="form" method="POST" action="/">
                        

                          <pre>  <input type="text" class="hidden" value=""  name="question_id"> <input type="text" class="hidden" value="" name="sub_categories">         <input type="text" class="hidden" value="" name="pg">Question no:            Question ID:               <input type="text" class="hidden" value="" name="question_id">Question  Marks:             Time:    </pre>

                        <br><b>Question: {!! $questions->question_description !!} </b>

                        @foreach($option as $data)
                            <br> <input type="checkbox" value="" name=""> 
                        @endforeach

                        <br><input type="submit" name="submit" value="Submit" class="btn btn-success">

                        <a href="/" value="Skip" name="skip" class="btn btn-success">Skip</a>

                        <a href="" Value="End Exam" name="End_EXam" class="btn btn-success">End Exam</a>
                    </form>

This is the code of from in the question page. When i submit answer selected all the answers than i found in debug that given below. Debug Request

You can see the all the requested result are appear. What i wanted to add all the values that indicated in the image i want to add them and put the added

8 => "0"
9 => "1"
10 => "0"
$result=0+1+0;

result in variable. but problem is how to do that. how to add only desire portion of the requested array. I did not design any controller yet. Please help me to solve this problem. Thank You in Advance.



via Atikur Rahaman

Advertisement