php - 如果结果 = 0,我如何禁用表格行
问题描述
你好,我的桌子在这里
截图在这里
汇总表 主 表现在我想在汇总表中如果“Menge” = 0,则表格行不会显示在汇总中,这意味着在实际图片中只有“10.95:7”必须蜜蜂显示我当前的 zhhe 汇总表的表格代码
<div class="box">
<div class="box-header">
<h3 class="box-title">Zusammenfassung</h3>
</div>
<div class="box-body">
<table class="table table-bordered table-striped">
<tr>
<th>Ware</th>
<th>Menge</th>
</tr>
<tbody>
<tr>
<td>4.95</td>
<td><?php echo $count->countRow($lid, 4.95); ?></td>
</tr>
<tr>
<td>5.95</td>
<td><?php echo $count->countRow($lid, 5.95); ?></td>
</tr>
<tr>
<td>7.95</td>
<td><?php echo $count->countRow($lid, 7.95); ?></td>
</tr>
<tr>
<td>9.95</td>
<td><?php echo $count->countRow($lid, 9.95); ?></td>
</tr>
<tr>
<td>10.95</td>
<td><?php echo $count->countRow($lid, 10.95); ?></td>
</tr>
<tr>
<td>11.95</td>
<td><?php echo $count->countRow($lid, 11.95); ?></td>
</tr>
<tr>
<td>12.95</td>
<td><?php echo $count->countRow($lid, 12.95); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
和类函数
public function countRow($lid, $price){
$result = $this->sql->query("SELECT count(*) FROM lieferschein2_ware where ean = '$price' and l_id = $lid");
$res = mysqli_fetch_array($result);
if($result->num_rows === 0){
return 0;
}else{
return $res["count(*)"];
}
}
表函数显示主表和用户信息
<div class="box-body">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>ID</th>
<th>Preis</th>
<th>status</th>
<th>Aktion</th>
</tr>
</thead>
<tbody>
<?php while($waren = mysqli_fetch_array($ware)) {
echo "<tr>";
echo "<td>" . $waren["id"] . "</td>";
echo "<td>" . $waren['ean'] . "</td>";
echo "<td>" . $waren['status'] . "</td>";
echo '<td><form method="post"><button type="submit" name="del" value='. $waren["id"] .' class="btn btn-danger btn-xs">Löschen</button></a></form></td>';
echo "</tr>";
}
?>
</tbody>
<tfoot>
<tr>
<th>ID</th>
<th>Preis</th>
<th>status</th>
<th>Aktion</th>
</tr>
</tfoot>
</table>
</div>
</div>
解决方案
menge
您需要在要检查的每一行大于 0之前应用 if 条件,如下所示:
<div class="box">
<div class="box-header">
<h3 class="box-title">Zusammenfassung</h3>
</div>
<div class="box-body">
<table class="table table-bordered table-striped">
<tr>
<th>Ware</th>
<th>Menge</th>
</tr>
<tbody>
<?php if ($count->countRow($lid, 4.95) > 0) { ?>
<tr>
<td>4.95</td>
<td><?php echo $count->countRow($lid, 4.95); ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
你需要if
对每一行应用这个条件。
推荐阅读
- python - 带有熊猫数据框列表的numpy数组
- c# - C# - 一元 ^ 做什么?
- python - LSTM:如何在时间序列中预测下个月的值
- omnet++ - Omnet++ lte 模式 4 矢量和标量文件错误
- assembly - 我实现 memset 的结果只打印更改,而不是整个结果字符串
- c# - 播种代码优先数据库会导致错误 --> 无法添加实体类型“$name”的种子实体,因为它设置了导航“$name”
- node.js - 如何在 Node.js 中需要模块中的变量 - 出现语法错误
- java - 动态插件架构。从 Spring Boot 应用程序的目录中加载 jar 文件
- json - 获取每个嵌套 json 值的完整路径
- python - Python:def中的变量