查看代码:使用laravel中的数据库检索值重定向到同一页面?
<li class="active"><a href="#tab_1" data-toggle="tab" id="versiontab"
onclick="window.location='{{ url("versiondb") }}'" >Version
Database</a></li>
这是我的看法代码。此也.Onclicking的标签中的URL重定向作品标签。
路线代码:
Route::get('versiondb','[email protected]');
Controllercode:
public function select()
{
$users=debModel::all();
return redirect()->back()->with($users);
}
这应该从数据库获取的值,重定向回到同一页面,并在表格中显示retreived值。但我在这里得到一个错误,因为$ users undefined
内相同的视图(上面指定的):
<table class="table" id="table">
@foreach($users as $users)
<thead>
<tr class="header">
<th valign="middle" width="3%">Versions</th>
<th valign="middle" width="2%">Supported versions</th>
<th valign="middle" width="10%">Release Date</th>
<th valign="middle" width="3%">Type</th>
<th valign="middle" width="10%">Description</th>
<th valign="middle" width="3%">Actions</th>
<th valign="middle" width="3%">Downloader</th>
<!--<th valign="middle" width="3%">Beta code</th>-->
</tr>
</thead>
<tbody>
<tr>
<td>{{$users->versions}}</td>
<td></td>
</tr>
@endforeach
</tbody>
</table>
我认为这是发生错误的地方。
对不起,先生,状态并没有工作 –
但是当我把它重定向到一些其他页面,并试图显示它的工作内容。 –
所以,我的建议是错误可能不会与$ users –