简体   繁体   English

如何在phpword中制作表格?

[英]How to make a table in phpword?

Bellow are my code, i get four column from these, but the result shows every one data will loop in four time in one column then it appear again in new column with the same data. 贝娄是我的代码,我从中得到四列,但结果显示每一个数据将在一列中循环四次,然后再次出现在具有相同数据的新列中。

    <?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
            }
        }
    }

model 模型

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();
    }
}

How to make table with four column, where the content of table will appear from right column to left and appear just one data in one time, after four column are full, it makes new row? 如何制作具有四列的表,其中表的内容从右列到左出现,一次只显示一个数据,四列填满后,会产生新的一行?

You can refer this code. 您可以参考此代码。 This is the way i have done table in view page 这是我在视图页面中完成表格的方式

 <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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM