【发布时间】:2021-09-15 13:48:44
【问题描述】:
我试图将一个参数从我的数据库传递到我的视图。
控制器
class StatisticsController extends Controller
{
public function statistic()
{
$data = DB::table('statisticforteacher');
return view('/statistics', compact('data'));
}
}
路线
Route::get('/statistics', 'StatisticsController@statistic');
刀片/视图
<table class="table-responsive"
style="border-collapse: separate; border-spacing: 10px 15px;">
<thead>
<th>Id</th>
<th>Kapitel</th>
<th>Frage</th>
<th>Anzahl der richtige Antwort</th>
<th>Anzahl der falsche Antwort</th>
<th>Richtige Rate</th>
</thead>
<tbody>
@foreach($data as $value)
<tr>
<td>{{$value -> Id}}</td>
<td>{{$value -> FrageBezeichnung}}</td>
<td>{{$value -> Kapitel}}</td>
<td>{{$value -> richtigeAntwort}}</td>
<td>{{$value -> falscheAntwort}}</td>
<td>{{$value -> richtigeRate}}</td>
</tr>
@endforeach
</tbody>
</table>
而从PHPMyAdmin中,我们可以看到一个名为statisticforteacher的表,每个列名也是对的。
但是,我仍然收到以下错误。
ErrorException 未定义属性: 照亮\数据库\MySqlConnection::$Id
【问题讨论】:
标签: php laravel laravel-blade