Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.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
Php 在td中显示类别名称_Php_Laravel - Fatal编程技术网

Php 在td中显示类别名称

Php 在td中显示类别名称,php,laravel,Php,Laravel,我想在td中显示子类别,但我喜欢带有一些格式的结果。输出在权重列上,因此需要帮助改进代码。如何逐个显示产品名称?为每个循环创建第二个td&它将进入称重列。我想以自动递增方式显示此产品\u名称$I 例外结果: product_name 1)face wash 2)face cream <div class="row"> <div class="col-md-12"> <div class="panel panel-defaul

我想在
td
中显示子类别,但我喜欢带有一些格式的结果。输出在权重列上,因此需要帮助改进代码。如何逐个显示
产品名称
?为每个循环创建第二个
td
&它将进入称重列。我想以自动递增方式显示此
产品\u名称
$I

例外结果:

  product_name
  1)face wash
  2)face cream
          <div class="row">
<div class="col-md-12">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title"><strong>Order summary</strong></h3>
        </div>
        <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-condensed">
                    <thead>
                        <tr>
                            <td><strong>Product Name</strong></td>
                            <td class="text-center"><strong>Weight</strong></td>
                            <td class="text-center"><strong>Quantity</strong></td>
                            <td class="text-right"><strong>Price</strong></td>
                            <td class="text-right"><strong>SubTotal</strong></td>
                        </tr>
                    </thead>
                    <tbody>
                        <!-- foreach ($order->lineItems as $line) or some such thing here -->
                        <tr>
                            <?php 
                            $subcategory=explode(',', $bill->name_of_subcategory);
                            $weight=explode(',', $bill->weight);
                            $orders_qty=explode(',', $bill->orders_qty);
                            $price=explode(',', $bill->price);
                            $orders_subtotal=explode(',', $bill->orders_subtotal);
                            ?>
                            <td><?php
                            $subcategory=explode(',', $bill->name_of_subcategory); 
                            for($i=0;$i<count($subcategory);$i++)
                            {
                              echo $subcategory[$i];
                            }
                            ?></td>
                            <td class="text-center">{{ $bill->weight }}</td>
                            <td class="text-center">{{ $bill->orders_qty }}</td>
                            <td class="text-center">{{ $bill->price }}</td>
                            <td class="text-center">{{ $bill->orders_subtotal }}</td>
                        </tr>
                        <tr>
                            <td class="thick-line"></td>
                            <td class="thick-line"></td>
                            <td class="thick-line"></td>
                            <td class="thick-line text-center"><strong>Subtotal</strong></td>
                            <td class="thick-line text-right">{{ $bill->total }}</td>
                        </tr>
                        <tr>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line text-center"><strong>SGST</strong></td>
                            <td class="no-line text-right">{{ $bill->sgst }}%</td>
                        </tr>
                        <tr>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line text-center"><strong>CGST</strong></td>
                            <td class="no-line text-right">{{ $bill->cgst }}%</td>
                        </tr>
                        <tr>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line text-center"><strong>IGST</strong></td>
                            <td class="no-line text-right">{{ $bill->igst }}%</td>
                        </tr>
                        <tr>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line text-center"><strong>Total</strong></td>
                            <td class="no-line text-right">{{ $bill->grand_total }}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
我的结果是:

face wash face cream
刀片文件代码:

  product_name
  1)face wash
  2)face cream
          <div class="row">
<div class="col-md-12">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title"><strong>Order summary</strong></h3>
        </div>
        <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-condensed">
                    <thead>
                        <tr>
                            <td><strong>Product Name</strong></td>
                            <td class="text-center"><strong>Weight</strong></td>
                            <td class="text-center"><strong>Quantity</strong></td>
                            <td class="text-right"><strong>Price</strong></td>
                            <td class="text-right"><strong>SubTotal</strong></td>
                        </tr>
                    </thead>
                    <tbody>
                        <!-- foreach ($order->lineItems as $line) or some such thing here -->
                        <tr>
                            <?php 
                            $subcategory=explode(',', $bill->name_of_subcategory);
                            $weight=explode(',', $bill->weight);
                            $orders_qty=explode(',', $bill->orders_qty);
                            $price=explode(',', $bill->price);
                            $orders_subtotal=explode(',', $bill->orders_subtotal);
                            ?>
                            <td><?php
                            $subcategory=explode(',', $bill->name_of_subcategory); 
                            for($i=0;$i<count($subcategory);$i++)
                            {
                              echo $subcategory[$i];
                            }
                            ?></td>
                            <td class="text-center">{{ $bill->weight }}</td>
                            <td class="text-center">{{ $bill->orders_qty }}</td>
                            <td class="text-center">{{ $bill->price }}</td>
                            <td class="text-center">{{ $bill->orders_subtotal }}</td>
                        </tr>
                        <tr>
                            <td class="thick-line"></td>
                            <td class="thick-line"></td>
                            <td class="thick-line"></td>
                            <td class="thick-line text-center"><strong>Subtotal</strong></td>
                            <td class="thick-line text-right">{{ $bill->total }}</td>
                        </tr>
                        <tr>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line text-center"><strong>SGST</strong></td>
                            <td class="no-line text-right">{{ $bill->sgst }}%</td>
                        </tr>
                        <tr>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line text-center"><strong>CGST</strong></td>
                            <td class="no-line text-right">{{ $bill->cgst }}%</td>
                        </tr>
                        <tr>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line text-center"><strong>IGST</strong></td>
                            <td class="no-line text-right">{{ $bill->igst }}%</td>
                        </tr>
                        <tr>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line"></td>
                            <td class="no-line text-center"><strong>Total</strong></td>
                            <td class="no-line text-right">{{ $bill->grand_total }}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

订单摘要
产品名称
重量
数量
价格
小计
{{$bill->weight}
{{$bill->订单数量}
{{$bill->price}
{{$bill->订单{u小计}
小计
{{$bill->total}
SGST
{{$bill->sgst}}%
CGST
{{$bill->cgst}}%
IGST
{{$bill->igst}}%
总计
{{$bill->grand_total}

您应该为每个结果创建一个


试试这个

<table>
<tr>
    <?php
    $subcategory=explode(',', $bill->name_of_subcategory); 
    foreach($subcategory as $row){ ?>
        <td>{{$row}}</td>
    <?php } ?>
</tr>
</table>

{{$row}}

您的问题是什么?如何将格式应用于子类别?我假设您的表编码正确吗?我更新了答案。我可以共享整个表吗?没有得到结果您想在列(并排)中显示结果还是在一行中显示每个结果?一个接一个