【发布时间】:2017-08-22 17:42:09
【问题描述】:
我正在使用 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>
PHP:
在我的listpetani.blade.php 中,我有一个空表,我想显示来自database 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]);
});
还有我页面中的表格:view in browser
我想在 laravel 5.4 中将数据库中的所有数据显示到我的视图中。有人可以帮帮我吗?
【问题讨论】:
-
在返回查看之前可以使用 did($petani); 来检查结果集吗
标签: php mysql laravel fetch laravel-5.4