php - How to print some specific part of a page via window.print() -


i'm working on form in php mysql. in page there form , below shown data of form in table format.now want print table structure thats why made print button as:

<span style="float:right;"><a href="javascript:window.print()" type="button" class="btn">print</a></span> 

but print whole page form field , table , want tableto print. here design of whole page form , table:

<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                   // print records                 $select = "select * company 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>&nbsp;</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 sure want delete <?php  echo $value[customer];?>?')"><i class="icon-trash"></i></a></td>                   </tr><?php }?>         </tbody>        </table> </fieldset> <form> </div> </body> 

so want print table not whole page.

use css hide elements don't want print:

@media print {     .control-group {       display: none;     } } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -