Use of Laravel--foreach

foreach traverses student information

Info.blade.php

 <table border="1" style="border-collapse:collapse" >
                <tr align="center">
                    <th>编号</th>
                    <th>学号</th>
                    <th>姓名</th>
                    <th>专业</th>
                    <th>班级</th>
                    <th>性别</th>
                </tr>

            @foreach($students as $item)
                <tr align="center">
                    <td><h3>{
    
    {
    
    $item['id']}}</h3></td>
                    <td><h3>{
    
    {
    
    $item['xh']}}</h3></td>
                    <td><h3>{
    
    {
    
    $item['xingming']}}</h3></td>
                    <td><h3>{
    
    {
    
    $item['zhuanye']}}</h3></td>
                    <td><h3>{
    
    {
    
    $item['banji']}}</h3></td>
                    <td><h3>{
    
    {
    
    $item['xingbie']}}</h3></td>
                </tr>


            @endforeach
        </table>

UserController.php

 public function index() {
    
    
        $students=$this->students;
        return view('admin.Info')->with(compact('students'));
 }

renderings
insert image description here

Guess you like

Origin blog.csdn.net/lj1641719803hh/article/details/123818473