So i want to show my article within the article category, it will like
category 1
..................
artikel1.1
artikel1.2
artikel1.3
more button
categori 2
..................
artikel2.1
artikel2.2
artikel2.3
more button
but after i tried it, it show only the first article for each category
category 1
...............
artikel1.1
more button
category 2
...............
artikel2.1
more button
here is my query
$sql_kategori_berita = "SELECT k.id,k.name,count(ar.id) as countartikel,";
$sql_kategori_berita .="ar.id as arid,ar.judul,ar.content, ar.kategori, ar.tanggal";
$sql_kategori_berita .=" FROM " .kategori_artikel::$nama_tabel. " k";
$sql_kategori_berita .=" LEFT JOIN " .artikel::$nama_tabel. " ar";
$sql_kategori_berita .=" ON k.id = ar.kategori";
$sql_kategori_berita .=" WHERE k.id NOT IN (1)";
$sql_kategori_berita .=" GROUP BY k.id";
$database->query($sql_kategori_berita);
$database->execute();
$nResults = $database->rowCount();
if($nResults > 0){
$i2 = 0;
while($row = $database->fetch()){
if($i2 % 3 == 0 || $i2 == 0){
echo "<div class=\"row\">";
}
$output ="<div class=\"col-md-4 col-sm-6 latest-news\">";
$output .="<h3 style=\"border-bottom: 2px solid #53555c;line-height: 1.5em;margin: 30px 0;\">{$row['name']}</h3>";
if($row['countartikel'] > 0){
$i = 0;
if($i <= 2){
$output .="<div class=\"row\">";
$output .="<div class=\"col-sm-12\">";
$output .="<div class=\"caption\"><a href=\"detail_artikel.php?i={$row['arid']}\"><b>{$row['judul']}</b></a></div>";
$phpdate = strtotime( $row['tanggal'] );
$mysqldate = date( 'F j, Y, g:i a ', $phpdate );
$output .="<div class=\"date\" style=\"font-size: 14px;\">{$mysqldate}</div>";
$content = html_entity_decode($row['content']);
$content = strip_tags($content);
$x = $content;
if(strlen($x)<=100)
$y = $x;
else
$y=substr($x,0,100) . '...';
$output .="<div class=\"intro\">{$y}</div>";
$output .="</div>";
$output .="</div>";
}
$i++;
echo $i;
if($row['countartikel'] > 3){
$output .="<div class=\"row\">";
$output .="<div class=\"col-sm-12\">";
$output .="<a href=\"list_artikel.php?i={$row['id']}\" class=\"btn\"><b>Selengkapnya »</b></a>";
$output .="</div>";
$output .="</div>";
}
}else{
$output .="<div class=\"row\">";
$output .="<div class=\"col-sm-12\">";
$output .="<div class=\"caption\"><b>Belum terdapat artikel...</b></div>";
$output .="</div>";
$output .="</div>";
}
$output .="</div>";
echo $output;
$i2++;
if($i2 % 3 == 0 || $i2 == $nResults){
echo "</div> <hr/>";
}
}
}
so what is wrong with my code?