我正在处理 php mysql 中的表单。所以在我的页面中有一个表格,下面我以表格格式显示了该表格的数据。现在我只想打印表格结构,这就是为什么我刚刚制作了一个 PRINT 按钮:
<span style="float:right;"><a href="javascript:window.print()" type="button" class="btn">PRINT</a></span>
但它会打印带有表单字段和表格的整个页面,我只想打印表格。这是我的整个页面的设计,带有表格和表格:
<html>
<head></head>
<body>
<div class="container">
<form class="form-horizontal" action="" method="post" name="userform1" id="company-form" enctype="multipart/form-data">
<?php if($_GET[id]){?>
<fieldset>
<legend>Add Company</legend>
<div class="control-group">
<label class="control-label">Company Name</label>
<div class="controls">
<input type="text" name="company" id="company" value="<?php echo $selup['company']?>">
</div>
</div>
<div class="control-group">another field</div>
<div class="control-group">another field</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn" name="submit" id="submit" value="Submit">Submit</button>
</div>
</div>
<table class="table table-bordered">
<tbody>
<tr>
<td>S.No.</td>
<td>Company Name</td>
<td>Type</td>
<td>Action</td>
</tr>
<?php
// to print the records
$select = "select * from company where type='Miscellaneous'";
$query1 = mysql_query($select);
while($value = mysql_fetch_array($query1)){ ?>
<tr>
<td><?php echo $value[id];?></td>
<td><?php echo $value[company ];?></td>
<td><?php echo $value[type];?></td>
<!--<td> </td>-->
<?php /*?><td><?php echo $value[amount];?></td>
<td><?php echo $value[date];?></td><?php */?>
<td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?id=<?php echo $value[id];?>&cmd=edit"><i class="icon-edit"></i></a>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?id=<?php echo $value[id];?>&cmd=delete" onclick="return confirm('Are you sure you want to delete <?php echo $value[customer];?>?')"><i class="icon-trash"></i></a></td>
</tr><?php }?>
</tbody>
</table>
</fieldset>
<form>
</div>
</body>
所以我只想打印表格而不是整页。