php - How not to display MySQL row if the row is empty -
i new php , trying solve this, went through many articles before asking here no better answer. fetching sql rows using mysqli_fetch_array($result)
if rows empty frontend displays empty row gives weird look. there should way not display empty rows database.
my code
<?php include_once("config.php"); date_default_timezone_set('asia/kolkata'); //$timestamp = time(); $day = "" . date("d"); $dayt= "t" . date("d"); $dayr= "r" . date("d"); $result = mysqli_query($mysqli, "select * time_table regd='". $_session['textbox1'] ."' order id desc"); while($res = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td style='width: 30%'>".$res[$dayt]."</td>"; echo "<td style='width: 30%'>".$res[$day]."</td>"; echo "<td style='width: 40%'>".$res[$dayr]."</td>"; } ?>
i suggest change select query exclude rows empty column(s).
for example:
$result = mysqli_query($mysqli, "select * time_table regd='". $_session['textbox1'] ."' , some_possibly_empty_column <> '' order id desc");
or if column allows null value, better:
$result = mysqli_query($mysqli, "select * time_table regd='". $_session['textbox1'] ."' , some_possibly_empty_column not null order id desc");
Comments
Post a Comment