php 仅打印表单预览
php print preview for form only
我是 php 代码的新手,我已经创建了一个打印按钮,但它显示了整个内容 page.I 想创建一个只打印表单内容的打印预览.那么我需要怎么做,请有人帮助我....这是我的代码。
reserve.php
<?php include('header_user.php');?>
<div id="container">
<div id="content">
<div id="contentleft">
<div class="reserve-form">
<h1>Make Reserve</h1>
<form action="reservation.inc.php" method="POST">
<!--username-->
<label for="uname"><b>Username</b></label>
<input type="text" name="uid" placeholder="Your username" required="">
<!--username-->
</br>
<!--person-->
<label for="hperson"><b>Person</b></label>
<select id="person" name="person">
<option selected hidden>How many person?</option>
<option value="1 Person">1 Person</option>
<option value="2 Person">2 Person</option>
<option value="3 Person">3 Person</option>
<option value="4 Person">4 Person</option>
<option value="5 Person">5 Person</option>
</select>
<!--person-->
</br>
<!--date-->
<label for="wdate"><b>Date</b></label>
<input type="text" name="bookdate" placeholder="dd-MM-yy" required="">
<!--date-->
</br>
<!--time-->
<label for="wtime"><b>Time</b></label>
<input type="text" name="booktime" placeholder="0.00pm" required="">
<!--time-->
</br>
<!--Select Table-->
<label for="rtable"><b>Table No</b></label>
<select id="table" name="booktable">
<option selected hidden>Choose your table</option>
<option value="T1">T1</option>
<option value="T2">T2</option>
<option value="T3">T3</option>
<option value="T4">T4</option>
<option value="T5">T5</option>
</select>
<!--end select-->
<button type="submit" name="confirm" class="loginbtn">Confirm</button>
<a class="print_btn" href="" onclick="window.print();">Print</a>
</form>
</div>
</div><!--contentleft-->
<?php include('sidebar.php');?>
</div><!--content-->
</div><!--container-->
<?php include('footer_user.php');?>
您可以使用 CSS3 媒体标签解决此问题。给您不想显示的部分添加 html class,例如 "no-print",然后将媒体打印条件添加到您的 css:
@media print {
.no-print {
display: none;
}
}
我是 php 代码的新手,我已经创建了一个打印按钮,但它显示了整个内容 page.I 想创建一个只打印表单内容的打印预览.那么我需要怎么做,请有人帮助我....这是我的代码。
reserve.php
<?php include('header_user.php');?>
<div id="container">
<div id="content">
<div id="contentleft">
<div class="reserve-form">
<h1>Make Reserve</h1>
<form action="reservation.inc.php" method="POST">
<!--username-->
<label for="uname"><b>Username</b></label>
<input type="text" name="uid" placeholder="Your username" required="">
<!--username-->
</br>
<!--person-->
<label for="hperson"><b>Person</b></label>
<select id="person" name="person">
<option selected hidden>How many person?</option>
<option value="1 Person">1 Person</option>
<option value="2 Person">2 Person</option>
<option value="3 Person">3 Person</option>
<option value="4 Person">4 Person</option>
<option value="5 Person">5 Person</option>
</select>
<!--person-->
</br>
<!--date-->
<label for="wdate"><b>Date</b></label>
<input type="text" name="bookdate" placeholder="dd-MM-yy" required="">
<!--date-->
</br>
<!--time-->
<label for="wtime"><b>Time</b></label>
<input type="text" name="booktime" placeholder="0.00pm" required="">
<!--time-->
</br>
<!--Select Table-->
<label for="rtable"><b>Table No</b></label>
<select id="table" name="booktable">
<option selected hidden>Choose your table</option>
<option value="T1">T1</option>
<option value="T2">T2</option>
<option value="T3">T3</option>
<option value="T4">T4</option>
<option value="T5">T5</option>
</select>
<!--end select-->
<button type="submit" name="confirm" class="loginbtn">Confirm</button>
<a class="print_btn" href="" onclick="window.print();">Print</a>
</form>
</div>
</div><!--contentleft-->
<?php include('sidebar.php');?>
</div><!--content-->
</div><!--container-->
<?php include('footer_user.php');?>
您可以使用 CSS3 媒体标签解决此问题。给您不想显示的部分添加 html class,例如 "no-print",然后将媒体打印条件添加到您的 css:
@media print {
.no-print {
display: none;
}
}