How to hide and show a column in html table based on a php condition.
$gid = $_SESSION['gid'];
if(gid == NO)
{
//display whole table
}
else{
// Dont dispaly the certain columns like gst,sgst.
}
The table would look like
<table class="table">
<thead>
<tr>
<th class="border-0 text-uppercase small font-weight-bold">Sl no</th>
<th class="border-0 text-uppercase small font-weight-bold">Spares Particulars</th>
<th class="border-0 text-uppercase small font-weight-bold">Amount</th>
<th class="border-0 text-uppercase small font-weight-bold">Quantity</th>
<th class="border-0 text-uppercase small font-weight-bold">GST %</th>
<th class="border-0 text-uppercase small font-weight-bold">GST AMT</th>
<th class="border-0 text-uppercase small font-weight-bold">CGST %</th>
<th class="border-0 text-uppercase small font-weight-bold">CGST AMT</th>
<th class="border-0 text-uppercase small font-weight-bold">SGST %</th>
<th class="border-0 text-uppercase small font-weight-bold">SGST AMT</th>
<th class="border-0 text-uppercase small font-weight-bold">Total AMT</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $i ?></td>
<td><?php echo $sparen ?></td>
<td><?php echo $row9['amt'] ?></td>
<td><?php echo $row9['quant'] ?></td>
<td><?php echo $row9['gstp'] ?></td>
<td><?php echo round($row9['amt']*($row9['gstp']/100)) ?></td>
<td><?php echo round($row9['gstp']/2) ?></td>
<td><?php echo round(($row9['amt']*($row9['gstp']/100))/2) ?></td>
<td><?php echo round($row9['gstp']/2) ?></td>
<td><?php echo round(($row9['amt']*($row9['gstp']/100))/2) ?></td>
<td><?php echo round((($row9['amt']*($row9['gstp']/100))+$row9['amt'])*$row9['quant']) ?></td>
</tr>
</tbody>
</table>
I don't want the columns like gst,gstamt,cgst,cgstamt,sgst,sgstamt to be displayed if the gid=YES. The problem is I tried js for it but that's not working. Can someone help me out with an easier solution.