Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6735413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:00:25+00:00 2026-05-26T11:00:25+00:00

Using PHP to print a variable in the footer of my HTML pages (before

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:00:25+00:00Added an answer on May 26, 2026 at 11:00 am

    My original question is if using CSS’s position: fixed; display:none; bottom:0; for the $footer’s print style is a feasible solution if $footer is dynamic page-to-page. My solution was to forgo the @media print style and just output my footer at the bottom of the generated output for every printed page, essentially:

        .footer {
            float:right;
        }
    
        <?php
    
        $page++;
        $break = 1;
    
        if ($break == 1){
            echo '<div class="footer">'.$footer.'</div>';
            $break = 0;
            echo '<hr class="break" />';
        }
        ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to extract the price from the bellow html page/link using php cURL
In PHP (for example), you can use this way to call a function using
I have a php file that I use to print pdf (using FPDF). In
I am using PHP 5's scandir($dir) function to iterate through a directory and print
I try to use amazon API using PHP. If I use print_r($parsed_xml->Items->Item->ItemAttributes) it show
Using PHP, what's the fastest way to convert a string like this: 123 to
Ho to store multiline text in a javascript variable; I am using PHP to
Note: I'm using Zend Framework, but I think most of this applies to PHP
Possible Duplicate: Using a javascript variable to set PHP variable I need to do
In PHP, I am able to use a normal function as a variable without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.