我有两个不同的表,答案表和问题表,我需要获得我设法检索的用户选择的问题 ID 和答案,我的问题来自同一个表单视图,我需要检索正确的答案和要点我在问题表中创建。从我看来,前两列是从答案表中检索的,因此我需要检索问题表中的后两列,请任何可以帮助我的人,以下是我尝试做的
这是我的观点:
<table class="table table-hover">
<thead class="thead-dark">
<tr>
<th scope="col">Question No</th>
<th scope="col">Answer</th>
<th scope="col">Correct Answer</th>
<th scope="col">Marks</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
@foreach($results as $data)
<tr>
<td>{{$i++}}</td>
<td>{{$data->question_id}}</td>
<td>{{$data->answer}}
<td>{{$data->qns_ans}}
<td>{{$data->qns_point}}
</tr>
@endforeach
</tbody>
</table>
这是我的控制器
public function index()
{
$results = Answers::all();
$qns = Questions::all();
return view('test.result')
->with('results', $results)
->with('qns', $qns);
}
DIEA
弑天下