as the title says I loop several divs which is supposed to be inside their parent but only the first child is inside
there are 2 php file, one is the template the other is for generating content
here are php code :
The Template
<div class="badan">
<?php include "isi.php" ?>
</div>
The Content (isi.php)
$sql=mysqli_query($con,"SELECT * FROM produk WHERE id_kategori2='4' ORDER BY id_produk DESC LIMIT 4");
echo "<div class='produk-box'>";
while ($r=mysqli_fetch_array($sql)){
include "diskon_stok.php";
echo "<div class='produk'>
<div class='produk-title'><a href='produk-$r[id_produk]-$r[produk_seo].html'>$r[nama_produk]</a></div>
<br />
<a href='produk-$r[id_produk]-$r[produk_seo].html'><img class='produkimg' src='../foto_produk/small_$r[gambar]' title='$r[nama_produk]'></a>
$divharga
</div>";
}
echo"</div>";
now the parent is div class=badan
while the childs are div class=produk-box
and the level 2 child is div class=produk
my intention is to make all of produk
echoed inside produk-box
while produk-box
is echoed inside badan
but what's really happening is the first produk
is echoed INSIDE produk-box
, the second produk
is echoed OUTSIDE of its parent div, and the rest of produk
is echoed OUTSIDE of badan
here is the screenshot of google chrome inspect element :
echo "<div class='produk-box>'";
should be
echo '<div class="produk-box">';