【发布时间】:2018-12-10 06:28:50
【问题描述】:
如何根据php条件隐藏和显示html表中的列。
$gid = $_SESSION['gid'];
if(gid == NO)
{
//display whole table
}
else{
// Dont dispaly the certain columns like gst,sgst.
}
表格看起来像
<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>
如果 gid=YES,我不希望显示像 gst,gstamt,cgst,cgstamt,sgst,sgstamt 这样的列。问题是我为此尝试了js,但这不起作用。有人可以帮助我提供更简单的解决方案吗?
【问题讨论】:
-
在页面顶部设置一个变量并在 HTML 部分添加 IF 条件以通过检查该值来显示或隐藏。
标签: javascript php html css