I'm trying to show data in table format from my DB. thead
shows up in the table, but the tbody
won't show up. I think, the problem is in the @foreach
function. Because, I have tried to type something outside the @foreach
function, and it shows up. And, I have tried to move the @foreach
inside <tr>
, but the result is just the same. Here's a part of my code:
<table class="table table-striped table-bordered" border="1px solid black">
<thead>
<tr>
<td>ID</td>
<td>Name</td>
<td>Created At</td>
<td>Updated At</td>
<td>Date of birth</td>
<td>Gender</td>
<td>Action</td>
</tr>
</thead>
<tbody>
@foreach($student as $key => $value)
<!--$student is imported from another file,
with this function: $student = Student::all()-->
<tr>
<td>{{$value->id}}</td>
<td>{{$value->name}}</td>
<td>{{$value->created_at}}</td>
<td>{{$value->updated_at}}</td>
<td>{{$value->dob}}</td>
<td>{{$value->gender}}</td>
<td><a href="{{URL::to('student/' . $value->id)
}}">Show</a> |
<a href="{{URL::to('student/' . $value->id)
.'/edit'}}">Edit</a> |
<form method="post" action="<?php echo url('/')
."/student/".$value->id."/delete";?>">
<input type="hidden" name="_token" value="
{!!csrf_token() !!}">
<div class="form-group">
<div>
<button type="submit" class=
"btn btn-warning">Delete</button>
</div>
</div>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
Hope you can help. Thanks.