Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.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_Php 7.1 - Fatal编程技术网

Php 如何基于数组在表中显示结果

Php 如何基于数组在表中显示结果,php,php-7.1,Php,Php 7.1,这里我有一个数组,我想以表格格式显示数组值,我是PHP7.1新手,如果有人知道方法-更新我的答案,我尝试过,但我无法得到答案 打印(公司责任) 桌子 单位 除名数目 公司地址 行动 1 5 TCS 编辑 删除 试试这个 <table> <thead> <tr> <td>Company Id</td> <td>Company Name</td> <td>no Of Divisi

这里我有一个数组,我想以表格格式显示数组值,我是PHP7.1新手,如果有人知道方法-更新我的答案,我尝试过,但我无法得到答案

打印(公司责任)

桌子


单位
除名数目
公司地址
行动
1
5
TCS
编辑
删除
试试这个

<table>
<thead>
<tr>
    <td>Company Id</td>
    <td>Company Name</td>
    <td>no Of Division</td>
    <td>Company Address</td>
    <td>Company Status</td>
</tr>
</thead>
<tbody>
<?php
foreach ($companyResponse['data'] as $result) { ?>
    <tr>
        <td><?php echo $result['companyId']; ?></td>
        <td><?php echo $result['companyName']; ?></td>
        <td><?php echo $result['noOfDivision']; ?></td>
        <td><?php echo $result['companyAddress']; ?></td>
        <td><?php echo $result['companyStatus']; ?></td>
    </tr>

    <?php
}
?>
</tbody>

公司Id
公司名称
除名数目
公司地址
公司状况
<table id="demo-dt-basic" class="table table-striped table-bordered" cellspacing="0" width="100%" style="">
    <thead>
        <tr>
            <th>Company</th>
            <th>No of Division</th>
            <th >Company Address</th>
            <th>Action</th>
        </tr>
    </thead>
<tbody>
    <tr>
        <?php
            $companyResponse = GetResponse(API_URL.'getCompanies');
        ?>
        <td>1</td>
        <td>5</td>
        <td>TCS</td>
      <td>
         <button class="btn btn-success actionbtn"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Edit</button>
         <button class="btn btn-danger actionbtn" data-toggle="modal" data-target="#DeleteModal"><i class="fa fa-trash-o" aria-hidden="true"></i> Delete</button>
      </td>
   </tr>
</tbody>
</table>
<table>
<thead>
<tr>
    <td>Company Id</td>
    <td>Company Name</td>
    <td>no Of Division</td>
    <td>Company Address</td>
    <td>Company Status</td>
</tr>
</thead>
<tbody>
<?php
foreach ($companyResponse['data'] as $result) { ?>
    <tr>
        <td><?php echo $result['companyId']; ?></td>
        <td><?php echo $result['companyName']; ?></td>
        <td><?php echo $result['noOfDivision']; ?></td>
        <td><?php echo $result['companyAddress']; ?></td>
        <td><?php echo $result['companyStatus']; ?></td>
    </tr>

    <?php
}
?>
</tbody>