我正在使用Laravel 5.4,我想从我的视图页面(listpetani.blade.php)查看数据库中的数据.
这是我的项目的代码:
HTML:
<div class="table-responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
<tr>
<th><strong>No</strong></th>
<th><strong>Nama Petani</strong></th>
<th><strong>Alamat</strong></th>
<th><strong>No. Handphone</strong></th>
<th><strong>Lokasi</strong></th>
</tr>
</thead>
<tbody>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
PHP:在我listpetani.blade.php的表中我有一个空表,我想显示来自数据库tbl_user的数据 :
Route::get('listpetani', function () {
$petani = DB::table('tbl_user')->pluck('id_user', 'username', 'alamat', 'no_telp', 'id_lokasi');
return view('listpetani', ['petani' => $petani]);
});
Run Code Online (Sandbox Code Playgroud)
我页面中的表格:在浏览器中查看
我想在laravel 5.4中将数据库中的所有数据显示到我的视图中.有谁能够帮我?