【问题标题】:How to make a table in phpword?如何在phpword中制作表格?
【发布时间】:2016-05-27 02:28:08
【问题描述】:

下面是我的代码,我从中得到四列,但结果显示每个数据将在一列中循环四次,然后它再次出现在具有相同数据的新列中。

    <?php
    $tampil_data = $this->in_elektronik_model->tampil_data(); //load data
    foreach ($tampil_data as $tampildata) { 
        for ($i = 0; $i < 4; $i++) {
            $table->addRow(500); //make new row
            for ($j = 0; $j < 4; $j++) {
                $table->addCell(2000)->addText(htmlspecialchars($tampildata->elektronik_nama)); //content of table
            }
        }
    }

型号

function tampil_data() {
    $this->db->where('elektronik_status_aktif', 0);
    $tampil = $this->db->get('in_elektronik');
    if ($tampil->num_rows() > 0) {
        return $tampil->result();
    } else {
        return array();
    }
}

如何制作四列的表格,表格的内容会从右列向左出现,一次只出现一条数据,四列填满后,再做新的一行?

【问题讨论】:

  • 你也可以使用html和php

标签: php mysql codeigniter phpword


【解决方案1】:

您可以参考此代码。这是我在视图页面中完成表格的方式

 <table border="1">
     <tr role="row">
   <th  width="5%">Featured Id</th>                                   
    </tr>
    <?php
     if(!empty($results))
       {

            foreach ($results as $row) {
             ?><tr>  
    <td class=" "><?php echo $row->fet_id; ?></td>  

        </tr>  

              <?php }}
?>                                         
     </table>

【讨论】:

  • 我想导出ms word的数据,所以不会检测css类。
  • 不需要css类
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-10-24
  • 2017-02-19
  • 1970-01-01
  • 2020-05-13
  • 2018-09-23
  • 2013-03-10
  • 1970-01-01
相关资源
最近更新 更多