How to print the specific table column using JQuery?
<p>I am trying to print the specific table column.
For example this is the table:</p>

<pre>
|  Name  |  Address |  Contact  |  Add  | Edit | Delete |
|    jj  |     ddd  |  1234564  |   +   |   -  |   x    |
</pre>

<p>The desired scenario here is when I click the print button, the name, address and contact should only be viewed in the print preview.</p>

<pre>
|  Name  |  Address |  Contact  |
|    jj  |     ddd  |  1234564  |
</pre>

<p>Now the problem is the add, edit and delete columns are include in the print preview so how do I remove them. I tried but it doesn't work.</p>

<p>Here's the code for Jquery print:</p>

<pre><code>$('.print_stud').click(function() {
        w=window.open();    
        w.document.write('&lt;html&gt;&lt;head&gt;&lt;title&gt;Requested Medicines&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;center&gt;&lt;h2&gt;Requested Medicines&lt;/h2&gt;&lt;/center&gt;') + '&lt;/body&gt;&lt;/html&gt;';
        w.document.write($('.p').html()); //to be printed
        w.print();
        w.close();  
});
</code></pre>

<p>Here's the code for displaying the data in php and html. This data will be used for print preview:</p>

<pre><code>&lt;?php 

    echo "&lt;div class='p'&gt;"; //the area to be printed

    while($test = mysqli_fetch_array($result))
    {
        $id = $test['id'];
?&gt;
    &lt;tr&gt;    
        &lt;td&gt;&lt;font color='black'&gt;&lt;?php echo $test['p_name'];?&gt;&lt;/font&gt;&lt;/td&gt;
        &lt;td&gt;&lt;font color='black'&gt;&lt;?php echo $test['date'];?&gt;&lt;/font&gt;&lt;/td&gt;
        &lt;td&gt;&lt;font color='black'&gt;&lt;?php echo $test['product_name'];?&gt;&lt;/font&gt;&lt;/td&gt;
        &lt;td&gt;&lt;font color='black'&gt;&lt;?php echo $test['drug_name'];?&gt;&lt;/font&gt;&lt;/td&gt;
        &lt;td&gt;&lt;font color='black'&gt;&amp;#8369;&lt;?php echo number_format($test['s_price'], 2); ?&gt;&lt;/font&gt;&lt;/td&gt;
        &lt;td&gt;&lt;font color='black'&gt;&lt;?php echo $test['quantity'];?&gt;&lt;/font&gt;&lt;/td&gt;
        &lt;td&gt;&lt;font color='black'&gt;&amp;#8369;&lt;?php echo number_format($test['sold'], 2); ?&gt;&lt;/font&gt;&lt;/td&gt;

    &lt;?php echo "&lt;div class='p'&gt;"; //The last area to be printed. The delete column should not be included ?&gt;            

        &lt;td&gt;&lt;center&gt;&lt;a href ='del.php?&amp;opr=delRequest&amp;id=&lt;?php echo $test['id'];?&gt;' title="Delete"&gt;&lt;span style="font-size:1.4em;" class="glyphicon glyphicon-remove-sign"&gt;&lt;/span&gt;&lt;/center&gt;&lt;/a&gt; &lt;!--Delete column---&gt;
    &lt;/tr&gt;

&lt;?php
    }
?&gt;  
</code></pre>