每次您的逻辑决定在发票中放置分页符时,告诉它也插入以下代码:
<?php include ("footer.php"); ?>
使用要放置在页脚中的简单 html 创建一个 footer.php 文件。以上代码假设your script和footer.php在同一个目录下。
编辑: 回答您的评论,
Include PHP.net 的行为与您实际上直接复制粘贴所有代码而不是包含它的行为完全相同。但是每个包含文件都应该有自己的<?php ?> 标签,无论何时需要。如果没有<?php ?> 标签,Control 只会输出它在此处看到的任何内容。
Footer.php 可以是一个简单的纯 HTML 文件:
<div id="footer">
Company XYZ (c)2000-2012 All Copyrights Reserved
Some other footer text.
</div>
你也可以把它命名为footer.html,但是如果以后,将来你决定把一些动态数据放在footer里,把.html改成.php就很难了在所有包含写在各种文件中的行中。
动态页脚示例:
<div id="footer">
Company XYZ (c)2000-2012 All Copyrights Reserved
<?php echo $who_printed." ".$who_authorized; ?>
</div>
当然这只是一个简单的例子。
在 html 页面中,您可以通过在外部链接的 .css 文件中使用以下 CSS 代码来强制使用 div:
#footer{
text-align: right;
height: 20px;
position:fixed;
margin:0px;
bottom:0px;
}
position:fixed; & bottom:0px; 就在这里。它迫使这个"footer" div 始终停留在底部,即使页面被滚动或其他东西。就像 Facebook 将其标题菜单放在顶部和聊天栏底部的方式一样。还可以定义左右属性
更新:好的,根据你的cmets,这里是示例代码:
在 CSS 样式部分,使用:
.signature{
border-bottom-style:solid;
font-size:14pt;
page-break-after:always;
text-align: center;
height: 20px;
width: 100%;
margin:0px auto;
position:fixed;
bottom:0px;
}
所有属性都是不言自明的。 Text-align 使文本居中对齐。 Width 正在使这个 div .signature 在页面上 100% 宽。需要将 div 两边的边距相等。 Margin 是说在顶部和底部放置 0px 边距,在左右两侧放置 auto。 Position 使其固定在视口/页面上。 Bottom 表示将 0px 从底部保留。
在页面正文中,使用以下代码:
<?php
foreach ($orders as $order) {
?>
//<div class="order">order1 go here </div>
//<div class="order">order2 go here </div>
//<div class="order">order3 go here </div>
//<div class="order">order4 go here </div>
<?php
} // for each ENDS
?>
<div class="signature">
Authorized by <?php echo $who_authorized; ?> |
Printed by <?php echo $who_printed; ?>
</div><!--//signature-->
它只是将您在 CSS 样式中定义的任何属性分配给 signature div。显然,您需要将此 sn-p 包装到您的逻辑中,该逻辑决定何时回显/引入 signature div。此外,$who_authorized 和 $who_printed 需要保持一些价值。
对于任何大于 3 行的块,我总是使用 PHP 解析器/控件 (?>) 并根据需要简单地编写 HTML。然后,当需要时,我再次输入 PHP (<?php)
如果你想使用 include,你可以省略最后 6 行(从我的代码中以 ?> 开始 & 以 <!--//signature--> 结尾,只需将这一行放在那里。
include ("footer.php");
?>
此选项还要求您在同一目录中创建一个名为footer.php 的文件,并在其中插入以下html代码。
<div class="signature">
Authorized by <?php echo $who_authorized; ?> |
Printed by <?php echo $who_printed; ?>
</div><!--//signature-->