Using laravel 5 version fetch records and display records in a table. If you using blade template, so it will be helpful for you. Follow the example and use source code in your project and done it quickly.
You need to create a table page and define some field, which are in your MySQL table. View the page and select data from database using laravel select query and fetch data and display in to the table using foreach loop. Follow the example and source code:
Table Page:
Create a simple table or bootstrap table:
<div class="row"> <table class="table" id=""> <thead> <tr> <th>Name</th> <th>E-mail</th> <th>Adress</th> <th>Phone</th> </tr> </thead> <tbody > @foreach($data as $val) <tr> <td>{{$val->name}}</td> </tr> @endforeach </tbody> </table> </div>
Routes.php:
Set page url link using ROute::get().
Route::get('user_details','UserController@user_details');
UserController:
<?php public static function user_details(){ $data=with(new UserModel)->getUserDetails(); return view('user_details')->with('data',$data); } ?>
Model:
<?php public function getUserDetails(){ $data=DB::table('Table Name')->get(); return $data; } ?>
Related posts