<?php
	require_once("koneksi.php");
    include 'header.php';
?>

	<!-- breadcrumbs -->
		<div class="breadcrumbs">
			<div class="container">
				<ol class="breadcrumb breadcrumb1">
					<li><span><i class="fa fa-sign-in" aria-hidden="true"></i><a href="login.php"> Masuk</a></span></li>
					<li class="active">Form Kelola Buku</li>
				</ol>
			</div>
		</div>
	<!-- //breadcrumbs -->
	<!-- register -->
		<div class="register">
			<div class="container">
				<h2>Edit Data Buku</h2>
				<div class="login-form-grids">
					<h5>Data Buku</h5>
					<?php
					$id_buku 	= mysqli_real_escape_string($koneksi, $_GET['id']);
					$cari 		= mysqli_query($koneksi, "SELECT * FROM t_buku, t_penerbit WHERE isbn='$id_buku'")or die(mysqli_error());
					$data = mysqli_fetch_array($cari);
					?>		
					<form  action="editbook_process.php" method="POST" enctype="multipart/form-data">
						<input type="hidden" name="id" placeholder="ISBN" value="<?php echo $data['isbn'] ?>" >
						<b>Judul Buku : </b>
						<input type="text" name="judul" placeholder="Judul Buku" value="<?php echo $data['judul'] ?>" >
						<b><br>Nama Pengarang :</b>
						<input type="text" name="pengarang" placeholder="Nama Pengarang" value="<?php echo $data['pengarang'] ?>" required/>
						<b><br>Nama Penerbit :</b>
						<input type="text" name="penerbit" placeholder="Nama Penerbit" value="<?php echo $data['nama_penerbit'] ?>" required/>
						<b><br>Kategori Buku :</b>
						<select class="form-control" name="kategori">
								<?php
									$kategori   = mysqli_query($koneksi, "SELECT * FROM t_kategori ORDER BY id_kategori");
									while($data = mysqli_fetch_array($kategori)) {
								?>
									<option value="<?= $data['id_kategori'];?>"><a href="categories.php?kd="><i class="fa fa-arrow-right" aria-hidden="true"></i><?php echo $data['nama_kategori']; ?></option>
								<?php   
									}
							 	?>
						</select>
						<b><br>Tahun Terbit :</b>
						<input type="text" name="tahun" placeholder="Tahun Terbit" value="<?php echo $data['tahun']; ?>" required/>
						<b><br>Harga per Eksemplar :</b>
						<input type="text" name="harga" placeholder="Harga per Eksemplar" value="<?php echo $data['harga'] ?>" required/>
						<b><br>Jumlah Tersedia :</b>
						<input type="text" name="jumlah" placeholder="Jumlah Tersedia" value="<?php echo $data['jumlah'] ?>" required/>
						<b><br>Keterangan Buku :</b>
						<input type="text" name="keterangan" placeholder="Keterangan Buku" value="<?php echo $data['keterangan'] ?>" required/>
						<b><br>File Gambar : <br></b>
						<div class="col-md-5 agileinfo_single">
							<img src="<?php echo $data['gambar']; ?>" class="img-responsive" required/>
						</div><br>
						<input type="file" name="gambar" accept="img/*" value="<?php echo $data['gambar']; ?>" required/>
						<input type="submit" name="edit" value="edit">
					</form>	
				</div>
				<div class="register-home">
					<a href="processbook.php">BATAL</a>
				</div>
			</div>
		</div>
	<!-- //register -->
	
<?php
	include 'footer.php';
?>