<?
//***************************************************
// http://www.niadesain.com
// Solusi Hemat Script Bisnis Online Anda
// Menerima Jasa Pembuatan Website & Template Website
//***************************************************

echo "<div class='media accordion-inner'>";
$batas   = 2;
$halaman = isset($_GET['halaman']) ? $_GET['halaman'] : null;

if(empty($halaman)){
	$posisi  = 0;
	$halaman = 1;
}
else{
	$posisi = ($halaman-1) * $batas;
}

$db->select("id_berita, id_user, judul, isi_berita, gambar, tanggal, counter, published", "berita", "published=1", "RAND() LIMIT $posisi,$batas");

if($db->num_rows() > 0) {
	while($row = $db->fetch_row()) {
	$adafoto = $row[4];
                echo "<table width='100%'>";
                echo "<tr><td>";
                echo "<div class='isi'>Post : $row[5] - dibaca : $row[6] kali</div>";
		echo "<div class='isi' align='left'><font color='#282D3A'><h4><a href=./?scrindo=detailberita&nid=$row[0]&id=$id><font color='#ff6700' class='judulberita'>$row[2]</font></a></h4></font></div>";
		if ($adafoto !=''){
                echo "<div class='pull-left'><a href=./?scrindo=detailberita&nid=$row[0]&id=$id><img class='img-responsive' src='images/news/".$row[4]."' width=239 height=102 hspace=0 border=1 align=left title='$row[2]'></a><img class='img' src='images/news/awblank.png' width=15 height=97 align=left></div>";
		}
		else
		{
                echo "<div class='pull-left'><a href=./?scrindo=detailberita&nid=$row[0]&id=$id><img class='img-responsive' src='images/news/noimage.jpg' width=239 height=102 hspace=0 border=1 align=left title='$row[2]'></a><img class='img' src='images/news/awblank.png' width=15 height=97 align=left></div>";
		}

		// Tampilkan hanya sebagian isi berita
  	  	//$isi_berita = nl2br($row[3]);
                $isi_berita = strip_tags(nl2br($row[3]));
        	$isi = substr($isi_berita,0,90);                // ambil sebanyak 90 karakter
                $isi = substr($isi_berita,0,strrpos($isi," ")); // spasi antar kalimat
		echo "<div class='media-body'><div align=left><font color='#282D3A'>$isi ...</font></div><a href=./?scrindo=detailberita&nid=$row[0]&id=$id><button type=\"submit\" name=\"submit\" class=\"btn btn-primary btn-lg\"> Baca Selengkapnya </button></a></div>";
		echo "</td></tr></table>";
		echo "<div><hr width=100% size=1 color=#CCCCCC></div>";
			}
} else {
	echo "<p>&nbsp;</p><p align=left class='isi'>Maaf belum ada berita untuk ditampilkan...</p><p>&nbsp;</p>";
}

echo "</div>";
?>