1

I have created a form that is handled by some PHP and echoed so it can be printed by the user. My problem is that when it prints it is printing everything. I would like to only print the text and not the print button or the url. I'll post the PHP code below.

    <?php

    $beq = $_REQUEST["beq"];
    $blq = $_REQUEST["blq"];
    $bwq = $_REQUEST["bwq"];

    if ($beq>0)
    {
        echo ("Berry (SPR0110) " .$beq);
    }

    if ($blq>0)
    {
        echo ("<br />Black (SPA0212) " .$blq);
    }

    echo '<br /><br /><a href="javascript:window.print()">Print</a>';

    ?>

2 Answers2

4

Quickest way:

<style type="text/css">
@media print {
    .hide-on-print { display:none; }
}
</style>

<?
$beq = $_REQUEST["beq"];
$blq = $_REQUEST["blq"];
$bwq = $_REQUEST["bwq"];

    if ($beq>0)
    {
        echo ("Berry (SPR0110) " .$beq);
    }

    if ($blq>0)
    {
        echo ("<br />Black (SPA0212) " .$blq);
    }

    echo '<div class="hide-on-print"><br /><br /><a href="javascript:window.print()">Print</a></div>';
methai
  • 8,835
  • 1
  • 22
  • 21
0

create a stylesheet with screen and print rules

Good rules for setting up print css?

Community
  • 1
  • 1
chepe263
  • 2,774
  • 22
  • 38