我正在使用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>
所以我只想打印表而不是整页.
使用css隐藏您不想打印的元素:
原文链接:https://www.f2er.com/php/135958.html@media print { .control-group { display: none; } }