Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.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 如何摆桌子_Php_Html_Codeigniter 3 - Fatal编程技术网

Php 如何摆桌子

Php 如何摆桌子,php,html,codeigniter-3,Php,Html,Codeigniter 3,我得到了这个数组结果 Array ( [0] => stdClass Object ( [Customer] => C-BTM [01/07/2016] => [02/07/2016] => [03/07/2016] => [04/07/2016] => [05/07/2016] =&g

我得到了这个数组结果

Array
(
    [0] => stdClass Object
        (
            [Customer] => C-BTM
            [01/07/2016] => 
            [02/07/2016] => 
            [03/07/2016] => 
            [04/07/2016] => 
            [05/07/2016] => 
            [06/07/2016] => 
            [07/07/2016] => 
            [08/07/2016] => 
            [09/07/2016] => 
            [10/07/2016] => 
            [11/07/2016] => 
            [12/07/2016] => 
            [13/07/2016] => 
            [14/07/2016] => 
            [15/07/2016] => 
            [16/07/2016] => 
            [17/07/2016] => 
            [18/07/2016] => 
            [19/07/2016] => 
            [20/07/2016] => 
            [21/07/2016] => 
            [22/07/2016] => 
            [23/07/2016] => 
            [24/07/2016] => 
            [25/07/2016] => 
            [26/07/2016] => 
            [27/07/2016] => 
            [28/07/2016] => 
            [29/07/2016] => 
            [30/07/2016] => 
            [31/07/2016] => 
        )
)

我有这个字段

Array (
    [0] => Customer
    [1] => 01/07/2016
    [2] => 02/07/2016
    [3] => 03/07/2016
    [4] => 04/07/2016
    [5] => 05/07/2016
    [6] => 06/07/2016
    [7] => 07/07/2016
    [8] => 08/07/2016
    [9] => 09/07/2016
    [10] => 10/07/2016
    [11] => 11/07/2016
    [12] => 12/07/2016
    [13] => 13/07/2016
    [14] => 14/07/2016
    [15] => 15/07/2016
    [16] => 16/07/2016
    [17] => 17/07/2016
    [18] => 18/07/2016
    [19] => 19/07/2016
    [20] => 20/07/2016
    [21] => 21/07/2016
    [22] => 22/07/2016
    [23] => 23/07/2016
    [24] => 24/07/2016
    [25] => 25/07/2016
    [26] => 26/07/2016
    [27] => 27/07/2016
    [28] => 28/07/2016
    [29] => 29/07/2016
    [30] => 30/07/2016
    [31] => 31/07/2016 )
它们都来自我的表,名为
ReportSalesPOSexcell
,其中的数据是
dynamic

$data['fields'] = $this->modelmodel->fields("ReportSalesPOSexcell"); //List Field Name
$data['hasil'] = $this->modelmodel->showdata("SELECT * FROM ReportSalesPOSexcell hasil"); // Result
现在我尝试将其插入到HTML表中。这是我的HTML表格

<table width="100%" id="tbl" class="table table-bordered table-striped">
                        <thead>
                            <tr align="center">
                            <th width="2%">No</th>
                                <?php foreach($fields as $header) { ?><th width="20%"><?=$header;?></th><?php } ?>
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
                        $no = 0;
                        if($hasil != ""){

                        echo "<tr>";
                        $no++;
                        echo "<td>".$no."</td>";
                        foreach($hasil as $hsl) {
                                echo "<td>".$hsl->C-BTM."</td>";
                                } 
                        }?>
                        </tbody>
                    </table>     

要将第一个或第二个数组添加到tbody中吗?

谢谢您的回复,我想将第二个数组添加到tbody中。第一个数组。抱歉。我认为第二个数组@YVS1102有问题,我已经尝试将数据模拟为常量变量,但总是得到和错误感谢您的帮助。我发现了如何处理我的问题
<?php 
                            $no = 0;
                            if($hasil != ""){
                                foreach($hasil as $hsl => $key)
                                {$no++;
                                ?>
                                <tr> <td width="20%"><?=$no;?></td>
                                    <?php foreach($fields as $header2) { ?>
                                        <td width="20%"><?=$hsl[$header2];?></td>
                                    <?php } ?>
                                </tr>
                                <?php
                                }
                            }?>