使用 PHP 显示每种类型的列

如何使用 foreach 和 if 使用 php 显示每种类型的一列


       @foreach ($detalles as $det)

                <tr>

                   if($det->inventariable == 1){

                   <td><font size="2">{{$det->cantidad}}</td>

                </tr>

                  } 

                  <tr>

                   if($det->inventariable == 2){

                   <td><font size="2">{{$det->cantidad1}}</td>

                  </tr>

                  }

                  <tr>

                   if($det->inventariable == 3){

                   <td><font size="2">{{$det->cantidad2}}</td>

                  </tr>

                   }

            @endforeach


九州编程
浏览 68回答 1
1回答

开心每一天1111

尝试这个@foreach ($detalles as $det)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <tr>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@if($det->inventariable == 1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><font size="2">{{$det->cantidad}}</td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><font size="2"></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><font size="2"></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@elseif($det->inventariable == 2)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><font size="2"></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><font size="2">{{$det->cantidad1}}</td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <td><font size="2"></td>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@elseif($det->inventariable == 3)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><font size="2"></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><font size="2"></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><font size="2">{{$det->cantidad2}}</td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@endif&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </tr>&nbsp; &nbsp; &nbsp; &nbsp; @endforeach
打开App,查看更多内容
随时随地看视频慕课网APP