<?php
	require_once("koneksi.php");
    include 'header.php';
    global $sql;

    $per_hal		= 6;
	$jumlah_record	= mysqli_query($koneksi, "SELECT * FROM t_artikel");
	$no 			= 1;
	$jum 			= mysqli_num_rows($jumlah_record);
	$halaman 		= ceil($jum / $per_hal);
	$page 			= (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
	$start 			= ($page - 1) * $per_hal;

    $sql = mysqli_query($koneksi, "SELECT * FROM t_artikel ORDER BY tanggal_dibuat DESC limit 8");
?>
	<!-- breadcrumbs -->
		<div class="breadcrumbs">
			<div class="container">
				<ol class="breadcrumb breadcrumb1 animated wow slideInLeft" data-wow-delay=".5s">
					<?php
	                if (isset($_SESSION['pengunjung'])) {
					    echo '
						<li><span><i class="fa fa-sign-in" aria-hidden="true"></i><a href="login.php"> Masuk</a></span></li>
						<li class="active">Daftar Artikel</li> ';
					}
					else {
						echo '
						<li><a href="index.php"><span class="glyphicon glyphicon-home" aria-hidden="true"></span>Beranda</a></li>
						<li class="active">Daftar Artikel</li> ';
					}
				?>
				</ol>
					<?php 
						if(isset($_POST['cari'])){
							$cari 	= $_POST['search'];
							$sql 	= mysqli_query($koneksi, "SELECT * FROM t_artikel WHERE judul_artikel LIKE '%$cari%' ORDER BY tanggal_dibuat");
						}
					?>
				<div class="w3l_search">
					<form action="" method="post">
						<input type="search" name="search" placeholder="Cari Judul Artikel" required="">
						<button type="submit" class="btn btn-default search" aria-label="Left Align" name="cari">
							<i class="fa fa-search" aria-hidden="true"> </i>
						</button>
						<div class="clearfix"></div>
					</form>
				</div>
			</div>
		</div>
	<!-- //breadcrumbs -->
	<!-- gourmet -->
		<div class="products">
			<div class="container">
					<div class="agile_top_brands_grids">
						<?php
							while($data = mysqli_fetch_array($sql)){
						?>
						<div class="col-md-6 top_brand_left">
							<div class="hover14 column">
								<div class="agile_top_brand_left_grid">
									<div class="agile_top_brand_left_grid1">
										<figure>
											<div class="snipcart-item block" >
												<div class="snipcart-thumb">
													<div class="col-md-5">
														<a href="singlearticle.php?kd=<?php echo $data['id_artikel'];?>"><img class="col-md-10" title="Klik Disini" src="<?php echo $data['gambar_artikel']; ?>" placeholder="Baca Selengkapnya Disini"/></a>
													</div>
													<div class="col-md-7">
														<center><h4><?php echo $data['judul_artikel']; ?></h4></center><br>
														<h6><?php echo $data['tanggal_dibuat']; ?></h6>
													</div>
												</div>
											</div>
										</figure>
									</div>
								</div>
							</div>
							<br>
						</div>
						<?php   
				      		}
				      	?>
						<div class="clearfix"> </div>
					</div>
				<nav class="numbering">
					<div class="pagination paging">
							<?php 
								for($page=1;$page<=$halaman;$page++){
							?>
							<li><a href="?page=<?php echo $page ?>"><?php echo $page ?></a></li>
							<?php
								}
							?>
					</div>
				</nav>
			</div>
		</div>
	<!-- gourmet -->

<?php
	include 'footer.php';
?>
