Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.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
Html 在laravel刀片表中显示数据库中的数据_Html_Laravel - Fatal编程技术网

Html 在laravel刀片表中显示数据库中的数据

Html 在laravel刀片表中显示数据库中的数据,html,laravel,Html,Laravel,我有一个HTML表,我想在其中显示从数据库表检索到的数据 我曾经用php成功地做到了这一点,但在Laravel中,表中没有显示任何内容:下面是用于在表中显示数据的代码 <tbody> @php $total_sales = 0; $comm_total = 0; @endphp @foreach ($comm as $data){ $comm_total += $data->sales_comm; $total_sales += $data->sa

我有一个HTML表,我想在其中显示从数据库表检索到的数据

我曾经用php成功地做到了这一点,但在Laravel中,表中没有显示任何内容:下面是用于在表中显示数据的代码

<tbody>
  @php
 $total_sales = 0;
 $comm_total = 0;
 @endphp

@foreach ($comm as $data){ 
  $comm_total += $data->sales_comm; 
  $total_sales += $data->sales_total;
<tr>
<td>{{$data->sales_date}}</td>
<td>{{$data->sales_total}}</td>
<td>{{$data->sales_comm}}</td>
</tr> 
@endforeach

你快到了。2件事:

第一:
@foreach($commas$data){
不需要
{

其次,在使用@php标记时,需要将所有内容封装在括号中。因此:

@php
$total_sales = 0;
$comm_total = 0;
@endphp
变成:

@php( $total_sales = 0 )
@php( $comm_total = 0 )
总之,它看起来如下所示:

@php( $total_sales = 0 )
@php( $comm_total = 0 ) // Note the omission of the ;

@foreach( $comm as $data )
    <tr>
        <td>{{$data->sales_date}}</td>
        <td>{{$data->sales_total}}</td>
        <td>{{$data->sales_comm}}</td>
    </tr> 
@endforeach 
使用
dd()
转储
$comm
的值作为起点。
@php( $total_sales = 0 )
@php( $comm_total = 0 ) // Note the omission of the ;

@foreach( $comm as $data )
    <tr>
        <td>{{$data->sales_date}}</td>
        <td>{{$data->sales_total}}</td>
        <td>{{$data->sales_comm}}</td>
    </tr> 
@endforeach 
// Make sure you call these at the top of your controller
use Auth;
use App\User;

public function show( Request $request )
{
    $comm = DB::table('bakerysales')
        ->where('customer_id', Auth::id() ) // Getting the Authenticated user id
        ->whereMonth('sales_date', $request->input('mn') )
        ->whereYear('sales_date', $request->input('yr') )
        ->get();

    return view('showCommission', compact('comm') );
}