i use code mount table header after getting values db
i experience trouble, results vertical instead horizontal:
where wrong?
expected
1 2 3 4 5 6
code
$query = '1,2,3,4,5,6'; $data = explode(',',$query); echo '<table>'; foreach($data $row){ echo '<tr>'; $row = explode(' ',$row); foreach($row $cell){ echo '<th>'; echo $cell; echo '</th>'; } echo '</tr>'; } echo '</table>';
simple html work good
<tr> <th>1</th> <th>2</th> <th>3</th> <th>4</th> <th>5</th> <th>6</th> </tr>
because creating new table row in every time in loop write <tr>
,</tr>
outside of loop , wtry
<table> <tr> <?php foreach($data $row){ $row = explode(' ',$row); foreach($row $cell){ echo "<td>{$cell}</td>"; } } ?> </tr> </table>
Comments
Post a Comment