Mysql
 SQL >> Datenbank >  >> RDS >> Mysql

In Laravel Daten aus der Datenbank auf einer View-Seite ausgeben

[GELÖST]

Danke euch, ich habe das Problem bereits gelöst.

Das ist der gelöste Code:

web.php (routes)

Route::get('listpetani', function () {
    $petani = DB::table('tbl_user')->get();
    return view('listpetani', ['petani' => $petani]);
});

und in meiner listpetani.blade.php

@foreach($petani as $key => $data)
  <tr>
    <th>{{$data->id_user}}</th>
    <th>{{$data->nama_user}}</th>
    <th>{{$data->alamat}}</th>
    <th>{{$data->no_telp}}</th>
    <th>{{$data->id_lokasi}}</th>
  </tr>
@endforeach

Die Daten werden per DB::table() abgerufen, als Variable an die View übergeben und dort mit @foreach durchlaufen.