Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在表的开头添加新行,而不是在底部添加?_Php_Html_Laravel_Phpmyadmin - Fatal编程技术网

Php 如何在表的开头添加新行,而不是在底部添加?

Php 如何在表的开头添加新行,而不是在底部添加?,php,html,laravel,phpmyadmin,Php,Html,Laravel,Phpmyadmin,我想在表的顶部开始插入一个新行,但我不知道如何插入 @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}}&l

我想在表的顶部开始插入一个新行,但我不知道如何插入

@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($dbData作为$newField)
//更新表格
@csrf
{{$i}
{{$newField->task}}//创建新列
{{$newField->description}
id}}value=“1”@if($newField->status==1)已选中@endif>
id}}>
没有开始
保存//将表单信息保存到表中

根据答案的第一个答案,表格没有开头或结尾(顶部或底部)

如果希望首先获取最后插入的数据,可以使用SQLOrderBy功能来实现这一点

这是一个很好的学校资源

在ForEach中使用前对其进行排序为什么要这样做。请改用
sortBy()
OrderBy('id','desc')
是您所需要的。它将在顶部获取最新数据。所以你不必在前端做任何排序。