<?php 
include "koneksi.php";
if (!isset($_SESSION["UserID"]))
{
	header("location:login.php?p=3");
}

$id="";
if (isset($_GET["id"]))
{
	$id=mysqli_real_escape_string($conn,$_GET["id"]);
}
$iniid=$id;
?>
<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="style.css">
<html>
  <head>
	<title> Modifikasi Motor </title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<?php
		include "part/jss.php";
	?>
	
  </head>
  <body>
	
	<div class="container">
	
		<div class="span12">
			<div class="alert alert-info">
					<b><center><h1>MODIFIKASI MOTOR</h1></center></b>
			</div>
					
					<?php
						include "part/menu.php";
						
						$q="SELECT * FROM kategori WHERE id='$id'";
						
						$res=mysqli_query($conn,$q);
						$dataKategori=mysqli_fetch_assoc($res);
					?>
			
			
		<div class="alert alert-info" align='center'>
			 <h3>Upload Kriteria Kategori <?php echo $dataKategori["nama"];?></h3>
			 <?php
				if (isset($_GET["p"]))
				{
					$p=mysqli_real_escape_string($conn,$_GET["p"]);
					if ($p=="3")
					{
						?>
							<div class="alert alert-primary" role="alert">
							  Kriteria berhasil diupdate!
							</div>
						<?php
					}
					else if ($p=="1")
					{
						?>
							<div class="alert alert-primary" role="alert">
							  Kriteria berhasil ditambah!
							</div>
						<?php
					}
					else if ($p=="2")
					{
						?>
							<div class="alert alert-primary" role="alert">
							  Kriteria berhasil dihapus!
							</div>
						<?php
					}
				}
			 ?>
			 <table class="table table-bordered">
			    <thead>
				  <tr>
				    <th>
					   Kriteria :
					</th>
					<th>
						Pilihan :
					</th>
				  </tr>
				</thead>
				<tbody>
				    <?php
						$q="SELECT * FROM kriteria WHERE id_kategori='". $_GET["id"] ."'";
						
						$res=mysqli_query($conn,$q);
						while ($row=mysqli_fetch_assoc($res))
						{
							?>
							  <tr>
							    <td>
								  <?php
									echo $row["nama"];
									
								  ?>
								</td>
								<td>
								  <a href="updatekriteria.php?id=<?php echo $row["id"];?>&ids=<?php echo $id;?>">Update</a>
								 
								  |
								  <a href="deletekriteria.php?id=<?php echo $row["id"];?>">Hapus</a>
								</td>
							  </tr>
							<?php
						}
					?>
				</tbody>
			 </table>
			 <a href="tambahkriteria.php?id=<?php echo $id;?>"><button type="button" class="btn btn-info">Tambah</button></a>
			 |
			 <a href="kategori.php"><button type="button" class="btn btn-info">Kembali</button></a>
		</div>		
	</div>
	
  
  </body>
</html>




