<?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"]);
}

?>
<!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 merk_motor WHERE id='$id'";
						
						$res=mysqli_query($conn,$q);
						$dataMerkMotor=mysqli_fetch_assoc($res);
					?>
			
			
		<div class="alert alert-info" align='center'>
			 <h3>Histori<?php echo $dataMerkMotor["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">
							  Nama motor berhasil dihapus
							</div>
						<?php
					}
					else if ($p=="1")
					{
						?>
							<div class="alert alert-primary" role="alert">
							  Nama motor berhasil ditambah
							</div>
						<?php
					}
				}
			 ?>
			 <table class="table table-bordered">
			    <thead>
				  <tr>
				    <th>
					   Tanggal :
					</th>
					<th>
					   Kategori :
					</th>
					<th>
					   
					</th>
				  </tr>
				</thead>
				<tbody>
				    <?php
						$user=$_SESSION["UserID"];
						$q="SELECT h.*,DATE_FORMAT(h.tanggal,'%d-%M-%Y') as tgl,k.nama ".
						   "FROM histori h ".
						   "INNER JOIN kategori k ON (k.id=h.id_kategori) ".
						   "WHERE h.id_user='". $_SESSION["UserID"] ."'";
						//echo $q;
						$res=mysqli_query($conn,$q);
						while ($row=mysqli_fetch_assoc($res))
						{
							?>
							  <tr>
							    <td>
								  <?php
									echo $row["tgl"];
								  ?>
								</td>
								<td>
								  <?php
									echo $row["nama"];
								  ?>
								</td>
								<td>
								  <a href="detailhistori.php?id=<?php echo $row["id"];?>">Detail</a>
								</td>
							  </tr>
							<?php
						}
					?>
				</tbody>
			 </table>
			 
		</div>		
	</div>
	
  
  </body>
</html>




