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 8982107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:30:18+00:00 2026-06-15T20:30:18+00:00

I have a HTML content in a variable like this. $message =<div> <table align=’center’>

  • 0

I have a HTML content in a variable like this.

$message ="<div>
    <table align='center'>
        <tr><td><h1>Reporte de Tipo de Documentos</h1></td></tr>
        <tr><td><h2>Farmaceutica MDC</h2></td></tr>
    </table>
</div>
<div>
    <table style='width:960px; margin:0 auto;'>
        <tr colspan='7'>
            <td><?php echo 'Fecha: '".$time = date('d/m/Y h:i:s A')."; ?></td>
        </tr>
        <tr bgcolor='#CCCCCC' height='30'>
            <td><b>Sr. No.</b></td>
            <td><b>Tipo Documento</b></td>
            <td><b>Cant. Pasos</b></td>
            <td><b>Costo</b></td>
            <td><b>Precio</b></td>
            <td><b>Balance</b></td>
            <td><b>Notifica Cliente</b></td>
        </tr>
    </table>";

I want to print a printout page of this HTML Content.
Like for web page we use

<script type="text/javascript">
    function printpage()
    {

        window.print();

    }
</script>.

So what i use to print the above HTML content?

  • 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-06-15T20:30:19+00:00Added an answer on June 15, 2026 at 8:30 pm

    How about embedding the contents of this page in HTML and adding a script to print it out automatically on page load?

    <?php
    $message ="<div>
        <table align='center'>
            <tr><td><h1>Reporte de Tipo de Documentos</h1></td></tr>
            <tr><td><h2>Farmaceutica MDC</h2></td></tr>
        </table>
    </div>
    <div>
        <table style='width:960px; margin:0 auto;'>
            <tr colspan='7'>
                <td><?php echo 'Fecha: '".$time = date('d/m/Y h:i:s A')."; ?></td>
            </tr>
            <tr bgcolor='#CCCCCC' height='30'>
                <td><b>Sr. No.</b></td>
                <td><b>Tipo Documento</b></td>
                <td><b>Cant. Pasos</b></td>
                <td><b>Costo</b></td>
                <td><b>Precio</b></td>
                <td><b>Balance</b></td>
                <td><b>Notifica Cliente</b></td>
            </tr>
        </table>";
    
    echo "<html><head></head><body>" . $message . "<script type='application/javascript'>window.onload=function(){window.print()}</script></body></html>";
    ?>
    

    To literally print the HTML code, you can sanitize the HTML like:

    echo "<html><head></head><body>" . htmlspecialchars($message, ENT_QUOTES) . "<script type='application/javascript'>window.onload=function(){window.print()}</script></body></html>";
    ?>
    

    More information about this:

    • How can I sanitize user input with PHP?
    • Sanitizing HTML input
    • PHP HTML sanitizer
    • https://www.php.net/manual/en/function.htmlspecialchars.php
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have HTML content in a variable like so: var data = <div
I want to parse a html content that have something like this: <div id=sometext>Lorem<br>
I have a html which looks roughly like this <div id=wallPostTemplate> <li id='comment-content--oOo-id-oOo-' class='comment-content'
I have to put microdata (schema.org) in html tag like this: <div class=list_item itemtype=http://schema.org/Hotel
Suppose, I have an HTML element, <div class = variable-content> </div> I want to
I have my HTML / razor code that looks like this: @model Content.Grid <tr
I have one html file like this one. <body class=iphone onLoad=doSomething()> <div id=title_wrapper><h2 id=title>[[[TITOLO]]]</h2></div>
I have python variable with a html content like >>>>a='<html><h1><a href=http://www.google.com>Link to Google<></h1></html>' How
With Rails, If I have a variable with HTML content, how do I output
Suppose we have this html content, and we are willing to get Content1, Content2,..

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.