Tahun baru, skill baru! 🚀. Masukkan kupon "skill2025" untuk diskon 30% di kelas apa saja

Pengulangan td dan tr dalam tabel


<?php
include 'config.php';
include 'get-mac.php';
?>
<table class="table table-bordered" border="1">
	<thead>
		<tr>
			<th>Product</th>
			<th>Description</th>
			<th>Availability</th>
			<th>Unit Price</th>
			<th>Qty</th>
			<th>Total</th>
		</tr>
	</thead>
	<?php
	$querytampil = mysqli_query($konn,"SELECT * FROM cart_order JOIN cart_order_detail USING(cart_id)
					                               JOIN product_item USING (item_id) WHERE mac_addr='$mac'");
		if(mysqli_num_rows($querytampil)>0){
			while($row=mysqli_fetch_array($querytampil)){
	?>
	<tbody>
		<tr>
			<td align="center">
				<img src="img/uploadproduct/<?php echo $row['filename']?>" height="125px" width="125px">
			</td>
			<td>
				<?php echo $row['item']?>
			</td>
			<td align="center">
				<b>In Stock</b>
			</td>
			<td align="center">
				$ <?php echo $row['price']?>
			</td>
			<td align="center">
				<?php echo $row['qty']?>
			</td>
			<td align="center">
				$ <?php $row['price']*$row['qty']?>
			</td>
		</tr>
	</tbody>
	<?php
		}}
	?>
</table>

hasilnya ini :

dan saya inginnya outputnya seperti ini :

Ada yg bisa bantu untuk posisi pengulangan tr atau td nya ?

avatar inginbelajar
@inginbelajar

95 Kontribusi 21 Poin

Diperbarui 7 tahun yang lalu

2 Jawaban:

Kayanya harus di looping satu-2 klw mau begitu gan, misalkan untuk product:

<tr>
 <th>Product</th>
<?php
if(mysqli_num_rows($querytampil)>0){
 while($row=mysqli_fetch_array($querytampil)){
?>
 <td align="center">
  <img src="img/uploadproduct/<?php echo $row['filename']?>" height="125px" width="125px">
 </td>
<?php }
} ?>
</tr>

avatar devio
@devio

101 Kontribusi 46 Poin

Dipost 7 tahun yang lalu

avatar codingforbabies
@codingforbabies

159 Kontribusi 53 Poin

Dipost 7 tahun yang lalu

Login untuk ikut Jawaban