我写了这段代码
应用\ HTTP \控制器\ processController.php
class ProcessController extends BaseController {
public function getData()
{
$data['data']=DB::table('process_table')->get();
if(count($data) > 0)
{
return view('process',$data);
}
else
{
return view('process');
}
} }
路线\ web.php
Route::get('/process', 'processController@getData');
资源\视图\ process.blade.php
我应该在刀片文件中写什么以及如何以表格格式打印$data
值
答案 0 :(得分:4)
数组的键值是您可以在视图中使用的变量的名称。因此,在您的情况下,:Exception::HTTP transport error: javax.net.ssl.SSLHandshakeException: No appropriate
protocol (protocol is disabled or cipher suites are inappropriate); nested exception is:
HTTP transport error: javax.net.ssl.SSLHandshakeException: No appropriate protocol
(protocol is disabled or cipher suites are inappropriate)
2017-11-07 06:17:28,857 INFO [STDOUT] java.rmi.RemoteException: HTTP transport error:
javax.net.ssl.SSLHandshakeException: No appropriate protocol
(protocol is disabled or cipher suites are inappropriate); nested exception is:
HTTP transport error: javax.net.ssl.SSLHandshakeException: No appropriate protocol
(protocol is disabled or cipher suites are inappropriate)
**********************************************************
将包含表$data
中的所有行。
要确保该变量存在,您可以使用process_table
函数。
现在你可以这样做:
isset
答案 1 :(得分:0)
你可以简单地转储它
@if (isset($data))
{{{ json_encode($data) }}}
@endif
答案 2 :(得分:0)
你应该试试这个:
应用\ HTTP \控制器\ processController.php 强>
class ProcessController extends BaseController {
public function getData()
{
$data['data']=DB::table('process_table')->get();
if(count($data) > 0)
{
return view('process',compact('data'));
}
else
{
return view('process');
}
}
}
<强>资源\视图\ process.blade.php 强>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1 style="color: purple;"><center><b>Process Data</b></center></h1>
<hr>
@if(isset($data))
<div class="tab-content">
<div role="tabpanel" class="tab-pane tab-margin table-area-margin active" id="profile">
<div class="table-responsive">
<table class="table payment-info-tbl">
<tr class="displaying-passages-title">
<th>Your Field</th>
</tr>
@foreach ($data as $datas)
<tr>
<td>{{$datas->yourField}}</td>
</tr>
@endforeach
</table>
</div>
</div><!--tab panel profile-->
</div><!--tab content-->
@else
<h1>No Data</h1>
@endif
</div>
</div>
答案 3 :(得分:0)
@if (isset($data))
<table>
@foreach ($data as $key => $row)
<tr>
<td>{{ $key }}</td>
<td>{{ (is_array($row)) ? json_encode($row) : $row }}</td>
</tr>
@endforeach
</table>
@endif