Reputation: 130
I want to show my database to table, but not just repeating in 1 row, I want it repeating in 4 column. In this code, the table show :
No Kursi
01
02
03
04
05
06
07
08
09
10
<table class="table table-bordered table-striped">
<tr>
<th ><strong>No Kursi</strong></th>
</tr>
<?php
$s = mysqli_query($koneksidb, "SELECT no_kursi FROM tkursi ORDER BY no_kursi ASC ");
$nomor = 1;
while ($kolomData = mysqli_fetch_array($s)) {
?>
<tr>
<td> <input type="radio" name="tambah3" value="O" required
<?php echo ($data7==$kolomData['no_kursi']) ? "checked" : "" ; ?>/>
<label class="inline" for="<?php echo $kolomData['no_kursi']; ?>">
<?php echo $kolomData['no_kursi']; ?> </label> </td>
</tr>
<?php } ?>
</table>
I want my table show in every 4 column than next row:
No kursi
01 02 03 04
05 06 07 08
09 10
Upvotes: 0
Views: 32
Reputation: 1190
Try this one :
<table class="table table-bordered table-striped">
<tr>
<th ><strong>No Kursi</strong></th>
</tr>
<?php
$s = mysqli_query($koneksidb, "SELECT no FROM tkursi ORDER BY no_kursi ASC ");
$nomor = 1;
while ($kolomData = mysqli_fetch_array($s)) {
?>
<?php if($nomor%4 == 1){ ?>
<tr>
<?php } ?>
<td> <input type="radio" name="tambah3" value="O" required
<?php echo ($data7==$kolomData['no_kursi']) ? "checked" : "" ; ?>/>
<label class="inline" for="<?php echo $kolomData['no_kursi']; ?>">
<?php echo $kolomData['no_kursi']; ?> </label> </td>
<?php if($nomor%4 == 0){ ?>
</tr>
<?php } ?>
<?php
$nomor++;
} ?>
</table>
Edited : It should be 2 equal signs if($nomor%4 == 0)
.
Upvotes: 1