Using PHP to print a variable in the footer of my HTML pages (before inserting a print page-break,) I attempted to use this solution. Essentially, I am wrapping the printed php variable in a <div>
set to @media print
and giving it position:fixed; bottom:0;
.
However, the variable overlaps every echoed instance of itself on every page printed. Is there a way to print a dynamic variable to the footer using this method that only shows the current page's variable's value?
Example code:
<html>
<head>
<style type="text/css">
.break {
page-break-after: always;
width:0px;
height:0px;
}
@media screen {
div.divFooter {
display: none;
}
}
@media print {
div.divFooter {
position: fixed;
bottom: 0;
}
}
</style>
</head>
<body>
<?php
$footer = ''; //footer is a dynamic variable whose value is set within a loop that also sets page breaks.
echo '<div class="divFooter">'.$footer.'</div>';
echo '<div class="break"></div>';
?>
</body>
</html>