I have my table here
I want in the Summary Table if "Menge" = 0 the table row won't show up in the summary. That means in the actual picture only "10.95: 7" has to be shown. My current table code for the summary table:
<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>
and the class function
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(*)"];
}
}
the table function which displays the main Table with the information for the user
<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>
You need to apply a if condition before every row to check menge
is greater than 0 as below:
<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>
And you need to apply this if
condition for every row.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.