1
1
1programmer2018-04-29 15:07:16
Laravel
1programmer, 2018-04-29 15:07:16

How to properly display the result from the database?

Hi all. There is a test
1) Question
Answer 1
Answer 2
Answer 3
2) Question 2
Answer 1
Answer 2
Answer 3 The
answers are always the same, the test is psychological.
The database is stored like this.
There is a table with questions
I display questions like this:

@foreach($questions as $question)
                    <li class="qName">{{ $question->question }}</li>
                    <ul id="b-question_{{ $loop->iteration }}">
                        <li><label><input name="answer_{{ $loop->iteration }}" type="radio" value="a" required>Постоянно</label></li>
                        <li><label><input name="answer_{{ $loop->iteration }}" type="radio" value="b" required>Иногда</label></li>
                        <li><label><input name="answer_{{ $loop->iteration }}" type="radio" value="c" required>Время от времени</label></li>
                    </ul>
                    <input type="hidden" name="count" value="{{ $loop->count }}">
                @endforeach

In the database, information about how the user answered is stored like this
[{"question_1":"b"},{"question_2":"a"},{"question_3":"a"},{"question_4":"c"},{"question_5":"b"},{"question_6":"b"},{"question_7":"b"},{"question_8":"c"},{"question_9":"c"},{"question_10":"a"},{"question_11":"a"},{"question_12":"c"},{"question_13":"c"},{"question_14":"b"},{"question_15":"a"},{"question_16":"a"},{"question_17":"b"},{"question_18":"a"},{"question_19":"c"},{"question_20":"a"},{"question_21":"a"},{"question_22":"a"},{"question_23":"c"},{"question_24":"b"},{"question_25":"c"},{"question_26":"a"},{"question_27":"a"},{"question_28":"b"},{"question_29":"b"},{"question_30":"a"},{"question_31":"c"},{"question_32":"c"},{"question_33":"c"},{"question_34":"c"},{"question_35":"b"},{"question_36":"a"},{"question_37":"a"},{"question_38":"c"},{"question_39":"b"},{"question_40":"c"},{"question_41":"b"},{"question_42":"c"},{"question_43":"a"},{"question_44":"b"},{"question_45":"c"},{"question_46":"c"},{"question_47":"a"},{"question_48":"c"},{"question_49":"a"},{"question_50":"c"},{"question_51":"c"},{"question_52":"c"},{"question_53":"b"},{"question_54":"c"},{"question_55":"c"},{"question_56":"a"},{"question_57":"b"},{"question_58":"b"},{"question_59":"a"},{"question_60":"a"},{"question_61":"b"},{"question_62":"a"},{"question_63":"b"},{"question_64":"a"},{"question_65":"b"},{"question_66":"b"},{"question_67":"b"},{"question_68":"a"},{"question_69":"c"},{"question_70":"b"},{"question_71":"c"},{"question_72":"a"},{"question_73":"b"},{"question_74":"a"},{"question_75":"c"},{"question_76":"c"},{"question_77":"b"}]

The task is this.
There is an admin panel in which information is displayed
5ae5b4cb59b6a289735228.png
. The screen shows that there is a link.
Opening the link, it should be displayed how the user answered the question
Question 1
Answer 1
Question 2
Answer 3
, etc.
I can get access to the answer like this
$ids[0]->answer [0]['question_1']
If now I insert the condition for the test that $ids[0]->answer[0]['question_1'] = and display the test word
On my page, it displays this word under each question.
How can I organize output correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yan-s, 2018-04-29
@Yan-s

If now I insert a test condition that $ids[0]->answer[0]['question_1'] = a and display a test word
. On my page, it displays this word under each question.

So you get exactly what you want? What is the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question