美好的一天。
这是我想输出到刀片页面的插图。
1. What was your dining experience?
Dine-in
Carry out
Delivery
2. How did you order?
Hotline
Online/Website
In-person
但是我不知道我应该在哪里调整,在我的PHP或Mysql中
在我的控制器中:
public function getsurveyquestion()
{
$questionstitle = DB::select('SELECT q_type,q_title FROM survey_question');
$questions = DB::select('SELECT q_type,q_title,qcategory_question as category FROM survey_question as sq LEFT JOIN
(SELECT id,qid,qcategory_question FROM survey_category_question) scq ON sq.id = scq.qid');
return view('/survey')
->with('question',$questions)
->with('questiontitle',$questionstitle);
}
在我的刀片页面中:
@foreach($questiontitle as $questions)
<b style="font-weight:300;"">{{$questions->q_title}}<br><br></b>
@foreach($question as $test)
{{$test->category}}<br><br>
@endforeach
@endforeach
这是我在刀片页面上的输出,这是错误的。
我的查询输出:
最佳答案
在刀片页面中修改:
@foreach($questiontitle as $questions)
<b style="font-weight:300;"">{{$questions->q_title}}<br><br></b>
@foreach($question as $test)
@if($questions->q_title == $test->q_title) {{-- add condition here --}}
{{$test->category}}<br><br>
@endif
@endforeach
@endforeach
关于php - 以正确的格式从数据库中获取数据到单选按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50827759/