这是我打印 qoutation 的代码。我已经为此使用了javascript。你能告诉我我应该怎么做才能只打印报价而不是整页吗?此代码打印完整的网页。我希望它以 pdf 格式打印
<?php
session_start();
if(empty($_GET['id']))
{
header("location:products.php");
}
require_once("include/database.php");
$_SESSION['p_id'] = $_GET['id'];
$query = "SELECT * from products WHERE p_id='".$_GET['id']."'";
$res = mysql_query($query,$connection) or die("wrong query " .mysql_error());
$row = mysql_fetch_array($res);
if(mysql_num_rows($res) != 1)
{
header("location:products.php");
}
?>
<head>
<link href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz|Open+Sans:400,600,700|Oswald|Electrolize' rel='stylesheet' type='text/css' />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title>Siddhivinayak Motors Pvt. Ltd. | Home</title>
<meta name="description" content="" />
<meta name="author" content="" />
<link rel="icon" href="images/favicon.ico" />
<link rel="stylesheet" href="css/style.css" media="screen" />
<link rel="stylesheet" href="css/skeleton.css" media="screen" />
<link rel="stylesheet" href="sliders/flexslider/flexslider.css" media="screen" />
<link rel="stylesheet" href="fancybox/jquery.fancybox.css" media="screen" />
<!-- HTML5 detect touch events -->
<script type="text/javascript" src="js/modernizr.custom.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body class="menu-1 h-style-1 text-1">
<div class="wrap">
<!-- - - - - - - - - - - - - - Header - - - - - - - - - - - - - - - - -->
<?php
include("include/header.php");
?>
<!-- - - - - - - - - - - - - - end Header - - - - - - - - - - - - - - - - -->
<aside id="sidebar" class="one-third column">
<div class="widget-container widget_compare">
<div class="widget-head">
<h3 class="widget-title">Price Quotation</h3>
</div>
<div class="entry-loan">
<form action="php/service.php" method="POST" name="service" id="service" >
<input type="hidden" name="id" value="<?php echo $_GET['id'] ?>"/>
<table>
<tr height="40px">
<td><label for="Vehicle name">Vehicle</label></td>
<td style="padding:0 0 0 12px; ">
<label>
<?php
echo $row['p_name'];
?>
</label>
</td>
</tr>
<tr height="40px">
<td><label for="Vehicle name">Model</label></td>
<td style="padding:0 0 0 12px; "><label>
<?php
echo $row['p_subname'];
?>
</label>
</td>
</tr>
<tr height="40px">
<td><label for="Vehicle name">Ex-Showroom price</label></td>
<td style="padding:0 0 0 12px; ">
<label><?php echo $row['showroom_price'] ?></label>
</td>
</tr>
<tr>
<td colspan="2" style="padding:70px 0 0 120px; ">
<i>As on. <?php
echo date("d-m-Y");
?>
<br/>
Tax and insurance extra.<br/>
All prices are subject to change without prior notice.<br/>
Please contact the dealership for exact prices and offers.<br/></i>
</td>
</tr>
<tr>
<td colspan="2" style="padding:0 0 0 12px; ">
</td>
</tr>
<tr>
<td></td>
<td style="padding:0 0 0 20px; ">
<script language="JavaScript">
if (window.print) {
document.write('<form><input type=button name=print value="Print" onClick="window.print()" class="button orange"></form>');
}
</script>
</td>
</tr>
</table>
</form>
</div>
<!-- - - - - - - - - - - - - end Container - - - - - - - - - - - - - - - - -->
</div><!--/ .main-->
<!-- - - - - - - - - - - - - - - Footer - - - - - - - - - - - - - - - - -->
<?php
include("include/footer.php");
?>
<!-- - - - - - - - - - - - - - - end Footer - - - - - - - - - - - - - - - - -->
</div><!--/ .wrap-->
<?php
include("include/login.php");
?>
<?php mysql_close($connection); ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery-1.7.2.min.js"><\/script>')</script>
<!--[if lt IE 9]>
<script src="js/selectivizr-and-extra-selectors.min.js"></script>
<![endif]-->
<script src="sliders/flexslider/jquery.flexslider-min.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="js/jquery.gmap.min.js"></script>
<script src="js/jquery-impromptu.js"></script>
<script src="js/custom.js"></script>
</body>
</html>