Php 需要laravel 5.4表格指南
您好,我是一个拉威尔初学者,当我做foreach的时候,它显示了所有单个项目的两倍,我应该用它做什么代码和ss如下 代码Php 需要laravel 5.4表格指南,php,laravel,Php,Laravel,您好,我是一个拉威尔初学者,当我做foreach的时候,它显示了所有单个项目的两倍,我应该用它做什么代码和ss如下 代码 门店名单 @foreach($outlets作为$outlet) 名字 姓氏 电子邮件 约翰 雌鹿 john@example.com @endforeach 问题是,您将整个表放在了循环中,这是错误的。您只需将tr放入循环中即可 试试这个: @foreach($outlets as $outlet) <tr> <td>John</td&g
门店名单
@foreach($outlets作为$outlet)
名字
姓氏
电子邮件
约翰
雌鹿
john@example.com
@endforeach
问题是,您将整个表放在了循环中,这是错误的。您只需将tr
放入循环中即可
试试这个:
@foreach($outlets as $outlet)
<tr>
<td>John</td>
<td>Doe</td>
<td>john@example.com</td>
</tr>
@endforeach
@foreach($outlets作为$outlet)
约翰
雌鹿
john@example.com
@endforeach
还有一件事,您也在循环中使用静态内容,而不是使用循环变量值。因此,不是:
<td>john@example.com</td>
john@example.com
有点像:
<td>{{ $outlet['name'] }}</td> <!-- where name is the index in outlet array -->
{{$outlet['name']}
问题是,您将整个表放在了循环中,这是错误的。您只需将tr
放入循环中即可
试试这个:
@foreach($outlets as $outlet)
<tr>
<td>John</td>
<td>Doe</td>
<td>john@example.com</td>
</tr>
@endforeach
@foreach($outlets作为$outlet)
约翰
雌鹿
john@example.com
@endforeach
还有一件事,您也在循环中使用静态内容,而不是使用循环变量值。因此,不是:
<td>john@example.com</td>
john@example.com
有点像:
<td>{{ $outlet['name'] }}</td> <!-- where name is the index in outlet array -->
{{$outlet['name']}
@foreach
应该在
中,而不是硬编码的内容,您应该使用$outlet
变量来获取名字、姓氏和电子邮件:
<div>
<h1 style="text-align: center">Lists of Outlets</h1>
<table class="table table-striped">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
@foreach($outlets as $outlet)
<tr>
<td>John</td>
<td>Doe</td>
<td>john@example.com</td>
</tr>
@endforeach
</tbody>
</table>
</div>
门店名单
名字
姓氏
电子邮件
@foreach($outlets作为$outlet)
约翰
雌鹿
john@example.com
@endforeach
@foreach
应该在
中,而不是硬编码的内容,您应该使用$outlet
变量来获取名字、姓氏和电子邮件:
<div>
<h1 style="text-align: center">Lists of Outlets</h1>
<table class="table table-striped">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
@foreach($outlets as $outlet)
<tr>
<td>John</td>
<td>Doe</td>
<td>john@example.com</td>
</tr>
@endforeach
</tbody>
</table>
</div>
门店名单
名字
姓氏
电子邮件
@foreach($outlets作为$outlet)
约翰
雌鹿
john@example.com
@endforeach
看起来另一个问题是,它实际上没有使用来自$outlet
的任何内容,而是每个都使用相同的静态值。看起来另一个问题是它实际上没有使用来自$outlet
的任何内容,而是每个都使用相同的静态值。