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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:49:06+00:00 2026-06-13T13:49:06+00:00

Since I am new to PHP I want to know how to print a

  • 0

Since I am new to PHP I want to know how to print a file content in PHP?
Actually my project consist of form from which data is choosed to print on a report but I want a print button on my form to print the report contents directly. Can anyone help please?
Here’s my code .. I have used CSS, html and PHP and it has two buttons view and print

<?php
       if ($_POST["submit"] == "View") {
?>      
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <head>
                <style type="text/css" media="all">
                    * {
                        margin:0px;
                        padding:0;
                    }
                    body {
                        margin:0px;
                        padding:0px;
                        font-family:Verdana, Arial, Helvetica, sans-serif;
                        font-size:12px;
                    }

                    span {
                        font-size:12px;
                    }

                    th, td {
                        width: 100mm;
                        height: 33.5mm;
                    }
                    table {
                        border-collapse:collapse;
                    }
                </style>
                <title>Hotel Label -  <?php echo $_SESSION["tourname"]; ?></title>
            </head>
            <body>
                <div style="margin:0px; padding:0; width:210mm; margin-top:12mm; margin-bottom:12mm; margin-left:0.5cm; margin-right:0cm; ">
<?php
        //echo $getno;
   /* } // View Tag Close
    else {

         ini_set("memory_limit", "50M");
         ob_start();*/

?>
            <style type="text/css" media="all">
                <!--
                body {
                    margin:0px;
                    font-family:Verdana, Arial, helvetica, sans-serif;
                    font-size:12px;
                }

                span {
                    font-size:12px;
                }

                td {
                    width: 100mm;
                    max-width: 100mm;
                    height: 33.5mm;
                    max-height:33.5mm;
                    top:0mm;
                }
                table {
                    border-collapse:collapse;
                }
                -->
            </style>
            <page backtop="13mm" backbottom="1mm" backleft="5mm" backright="5mm" style="font-size: 10px; font-family: Verdana;">
<?php

?>
                <?php

                $ctr16 = 0;
                $ctr16_2 = 0;
                $nctr = 0;
                $ctr = 0;
                $mctr = 0;
                $lblctr = 0;
                while ($lbl = mysql_fetch_assoc($get)) {
                    $ctr16++;
                    $ctr16_2++;
                    $nctr++;
                    $ctr++;
                    $lblctr++;
                    $getno--;

                    if ($ctr == 1) {
                        echo "<table border=\"0\" align=\"left\" style =\"width: 210mm;\">";
                        echo "\n <tr> \n ";
                        echo "\n <tr> \n ";
                        echo "\n <td style=\"width: 100mm; max-width: 100mm; height:33.5mm; padding-left:1mm;\" valign=\"top\"> \n";

                        if ($lblctr > 16) {
                         echo "<br>";
                         echo "<br>";
                        $lblctr = 1;
                    }

                    if ($ctr16 > 64) {
                        echo "<br>";
                        echo "<br>";
                        $ctr16 = 1;
                    }

                    }
                    else {
                        echo "\n <td style=\"width: 100mm; max-width: 100mm; height:33.5mm; padding-left:15mm;\" valign=\"top\"> \n";
                        if ($nctr > 16) {
                         echo "<br>";
                         echo "<br>";
                         $nctr = 1;
                    }
                    if ($ctr16_2 > 64) {
                        echo "<br>";
                        echo "<br>";
                        $ctr16_2 = 1;
                    }

                    }
                    echo "<br />". "<span><font size='3px'><b>$lbl[hotelname]</b></font>";
// echo "<font size='2px'>$lbl[hotelname]";

echo "<br />"."<br />"."<font size='2px'>Haji No.-$lbl[hajino]</font>";
echo "<br />"."$lbl[suffix] $lbl[surname] $lbl[name]$lbl[midname] <br />";

echo "<br />"."<font size='2px'><b>Room No - $lbl[roomno] &nbsp;&nbsp;&nbsp; Bus No - $lbl[busname]</font></b>";
echo "<br />";

echo "<br />";
echo "<br />";
echo "</span> ";

                   // echo "<br />";
                    echo "</td>";
                    if ($ctr == 2 || $getno == 0) {
                    echo '<br />';
                    $ctr = 0;
                    echo "</table>";

                    }
                }
                mysql_free_result($get);
                ?>

            </div>
        </body>
    </html>
  <?php

 } else($_POST["submit"]== "Print"){

     $filecontents = file_get_contents("hotel_label_print.php");
     print $filecontents;
 } ?>
  • 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-13T13:49:07+00:00Added an answer on June 13, 2026 at 1:49 pm

    You can use file_get_contents()
    (http://php.net/manual/en/function.file-get-contents.php)

    <?php
    $homepage = file_get_contents('filename.txt');
    echo $homepage;
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a new PHP project now, this time I want to
I am new to php and I want to only show specific footer content
since the new Auth Dialog from Facebook (for my App & homepage), I cannot
Since I'm new to Joomla I would like to know whether there is a
Okay, so here's what I want to do (NOTE: I'm stil new to PHP):
since im new to drupal7 and omega theme, I want a custom front page,
Hi I am totally new to php (I literally know nothing about it) but
HI I am pretty new in C# sphere. Been in php and JavaScript since
Coming from a PHP background, I'm trying to learn C++, since I find it
I want to use this mobile detection php file on a magento website and

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.