php - Displaying Explode data using loop -
i new in php. have code in use foreach loop display data in table of explode function.
here have question
the data in db
here see after aatir
there blank space. when use loop print data
<?php ini_set('error_reporting', e_all); $servername = "localhost"; $username = "root"; $password = ""; $dbname = "pacra1"; $conn = new mysqli($servername, $username, $password, $dbname); $sql = "select * `pacra_clients` `id` = 50"; $conn->multi_query($sql); $result = $conn->use_result(); echo $conn->error; $row = $result->fetch_assoc(); $liaison_one = $row['liaison_one']; $liaison_one_chunks = explode(",", $liaison_one); echo '<table border="01">'; foreach($liaison_one_chunks $row){ echo '<tr>'; $row = explode(',',$row); foreach($row $cell){ echo '<td>'; echo $cell; echo '</td>'; } echo '</tr>'; } echo '</table>'; ?>
the result of code is
in result can see there blank cell due blank space in data.
is possible can skip blank space in data???
yes possible. use continue.
foreach($row $cell){ if ($cell == "") continue; echo '<td>'; echo $cell; echo '</td>'; }
Comments
Post a Comment