php生成word文档更改页面

时间:2015-10-22 07:21:34

标签: php mysql ms-word

我试图从php + mysql生成单词。我找到了生成它的代码,我有3个查询。我想在每个循环中更改页面。那可能吗?现在我使用<hr>来分隔它。在示例中,我只有2个大循环,但在我的页面中我有10个循环,我希望在1页o字中有1个循环。这是我的代码

<?php
header("Content-type: application/vnd.ms-word");

header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; Filename=printorders.doc");

?> 

<?php 
include 'connection.php';
$result = $connection->query('SELECT * FROM main WHERE  (orderid = "100000002" OR orderid = "100000003") GROUP BY orderid ORDER BY orderid'); ?>


<?php   while($row = $result->fetch_array()) { 


    $result3 =  $connection->query("SELECT orderid, BillingStreet, City, Region FROM main WHERE BillingTelephone = '".$row["BillingTelephone"]."' group by orderid ORDER BY  `main`.`orderdate` ASC ");
        while($row3 = $result3->fetch_assoc()) { 
            $city =  $row3["City"];
            $region = $row3["Region"];
            $address = $row3["BillingStreet"];
            $idorder = $row3["orderid"];

        }
    ?>
<table border="1" width="100%" cellpadding="10" cellspacing="0" align="center" id="tbl">
    <thead>
        <tr>
            <th>id</th>
            <th>date</th>
            <th>name</th>
        <tr>
    </thead>
    <tbody>
        <tr>
            <td style="text-align:center;"><?php echo $idorder;?></td>
            <td style="text-align:center;"><?php echo $row["insert_date"];?></td>
            <td style="text-align:center;"><?php echo $row["CustomerName"];?></td>
        </tr>
    </tbody>
</table>       

<hr style="color: #f00;background-color: #f00;height: 10px;"> <!--here i want to change page-->
<?php 
} 
?>

1 个答案:

答案 0 :(得分:0)

如果您想使用分页符,可以添加此行

<br style="page-break-before: always">