【发布时间】:2020-02-09 13:49:10
【问题描述】:
我想在表格的开头插入一个新行,但我不知道怎么做?
@foreach ($dbData as $newField)
<form action="{{url('/update')}}" method="POST"> //update the form
@csrf
<input type="hidden" name="id" value="{{$newField->id}}">
<tr>
<td class="column"> {{$i}}</td>
<td class="column"> {{$newField->task}}</td> //make new column
<td class="column"> {{$newField->description}}</td>
<td>
<div class="form-check">
<input class="form-check-input" type="radio" name="status1" id={{$newField->id}} value="1" @if($newField->status == 1) checked @endif>
<label class="form-check-label" for={{$newField->id}}>
not started
</label>
</div>
<button type="submit">save</button> //save form information to the table
【问题讨论】:
-
在foreach中使用前先排序
-
你为什么要这么做。请改用
sortBy()。 -
OrderBy('id','desc')是您所需要的。它将在顶部获取最新数据。所以你不必在前端做任何排序。
标签: php html laravel phpmyadmin