<?php 
include "koneksi.php";
//if (!isset($_SESSION["UserID"]))
//{
	//header("location:login.php?p=3");
//}
$keyword="";
if (isset($_GET["cari"]))
{
	$keyword=mysqli_real_escape_string($conn,$_GET["cari"]);
}

$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";
					?>
			<div class="row">
				<table class="table">
					<thead>
					
					</thead>
					<tbody>
						<?php
							$q="SELECT rs.*,k.nama as kategori ".
							   "FROM referensi_sparepart rs ".
							   "INNER JOIN sparepart s ON (s.id=rs.id_sparepart) ".
							   "INNER JOIN kategori k ON (s.id_kategori=k.id) ".
							   "WHERE rs.detail LIKE '%$keyword%'";
							   //echo $q;
							   
							   //echo $row["id"];
							   
							$res2=mysqli_query($conn,$q);
							//print_r ($res2);
							while ($dataR=mysqli_fetch_assoc($res2))
							{
								?>
									<tr>
										<th>
										  Nama
										</th>
										<td>
											<?php
												//print_r($row);
												//echo "<br/>";
												///print_r($dataR);
												echo $dataR["kategori"]."_";
												//echo $row["id"];
												$z="SELECT * FROM sparepart WHERE id='".$dataR["id_sparepart"]."'";
												$res=mysqli_query($conn,$z);
												$motor=mysqli_fetch_assoc($res);
												//echo $motor["id_merkMotor"];
												
												$aa="SELECT * FROM kendaraan WHERE id='".$motor["id_merkMotor"]."'";
												$res3=mysqli_query($conn,$aa);
												$merkMotor=mysqli_fetch_assoc($res3);
												echo "Motor Untuk"."_".$merkMotor["nama"];
											?>
										</td>
									</tr>
									<tr>
										<th>
										  Detail
										</th>
										<td>
											<?php
												//print_r($row);
												//echo "<br/>";
												///print_r($dataR);
												echo $dataR["detail"];
											?>
										</td>
									</tr>
									<tr>
										<th>
										  Harga
										</th>
										<td>
											<?php
												//print_r($row);
												//echo "<br/>";
												///print_r($dataR);
												echo number_format($dataR["harga"],2);
											?>
										</td>
									</tr>
									<tr>
										<th>
										  Alamat
										</th>
										<td>
											<?php
										
												$b="SELECT * FROM user WHERE id='". $dataR["id_user"] ."'";
																$ress=mysqli_query($conn,$b);
																$dataUser=mysqli_fetch_assoc($ress);
																echo $dataUser["alamat"];
										
											?>
										</td>
									</tr>
									<tr>
										<td style="text-align:center" colspan="2">		
												<img style="height:300px" src="img/<?php echo $dataR["gambar"];?>"/>
											
										</td>
									</tr>
									<tr>
									   <td colspan="2">
										<br/><br/>
									   </td>
									</tr>
								<?php
							}
						?>
						
					</tbody>
					</table>
			</div>
	</div>
	
  
  </body>
</html>




