php - Hide empty td if count value is empty in datatables -
i have script works hidden null values in mysql db, empty values count them...so how can hide values too?
<table class="table table-bordered table-striped table-condensed bootstrap-datatable datatable" > <thead> <tr> <th>diagnósticos</th> <th class="center sorting_desc">casos vistos</th> </tr> </thead> <tbody> <? $sql = $conn->prepare("select diagnostico, count(diagnostico) ( select diagnostico diagnostico diagnosticon id_doctor = $id_doctor union select diagnostico1 diagnostico diagnosticon union select diagnostico2 diagnostico diagnosticon union select diagnostico3 diagnostico diagnosticon) t group t.diagnostico order count(diagnostico) desc "); $sql->execute(); while($row = $sql->fetch(pdo::fetch_assoc)) { echo "<tr>\n"; echo "<td>"; if (!empty($row["diagnostico"])) { echo $row["diagnostico"]."</td>\n"; } echo "<td>"; if (!empty($row["count(diagnostico)"])) { echo $row["count(diagnostico)"]."</td>\n"; echo "</tr>\n"; } } ?> </tbody> </table>
replace
count(diagnostico)
with
count(case when diagnostico = '' null else diagnostico end)
Comments
Post a Comment