美好的一天。
这是我想要输出到我的 Blade 页面的插图。
1. What was your dining experience?
Dine-in
Carry out
Delivery
2. How did you order?
Hotline
Online/Website
In-person
但是我不知道应该在哪里调整,在我的php中还是在我的Mysql
在我的 Controller 中:
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);
}
在我的 Blade 页面中:
@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
最佳答案
在您的 Blade 页面中修改:
@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/