Vote count:
0
I am a newbie in laravel and php. I cannot show the results of query in laravel. I wrote this in my program.
routes.php
Route::get('books/see', function()
{
return View::make('books.absen');
});
Route::post('books/absen','BookController@absen');
BookController.php
public function absen()
{
$ruang = Input::get('ruangn');
$results = DB::select( DB::raw("SELECT id, name, isbn, ta, tb FROM book WHERE ta = '$ruang'"));
return Redirect::to('books/see');
}
absen.blade.php
<select name="ruangn" class="form-control" method="post" action="{{URL::to('books/absen')}}">
<?php
for( $i=1; $i<19; $i++ )
{
?>
<option>
<?php echo $i;
}
?>
</option>
</select>
<input type="submit" name="submit" value="Oke" class="btn btn-info">
<table class="table table-bordered table-striped">
<thead>
<th>No</th>
<th>Name</th>
<th>ISBN</th>
<th>TA</th>
<th>TB</th>
</thead>
<tbody>
@foreach ($results as $value)
<tr>
<td>{{$value->id}}</td>
<td>{{$value->name}}</td>
<td>{{$value->isbn}}</td>
<td>{{$value->ta}}</td>
<td>{{$value->tb}}</td>
</tr>
@endforeach
</tbody>
</table>
And error is Undefined variable: results (View: ...\absen.blade.php) I very tired with this. Help please
asked 52 secs ago
View in laravel error undefined variable
Aucun commentaire:
Enregistrer un commentaire