<?php
 
//Including Database configuration file.
 
include "db.php";
 
//Getting value of "search" variable from "script.js".
 
if (isset($_POST['search'])) {
 
//Search box value assigning to $Name variable.
 
   $Name = $_POST['search'];
 
//Search query.
 
   $Query = "SELECT * FROM item WHERE name LIKE '%$Name%' LIMIT 5";
 
//Query execution
 
   $ExecQuery = MySQLi_query($con, $Query);
 
//Creating unordered list to display the result.
 
   echo '
 
<ul>
 
   ';
 
   //Fetching result from the database.
 
   while ($Result = MySQLi_fetch_array($ExecQuery)) {
 
       ?>
 
   <!-- Creating unordered list items.
 
        Calling javascript function named as "fill" found in "script.js" file.
 
        By passing fetched result as a parameter. -->
 
   <li onclick='fill("<?php echo $Result['model']; ?>")'>
 
   <a>
 
   <!-- Assigning searched result in "Search box" in "search.php" file. -->
 
   <div  id="output" class="form-group"> 
	<img src="<?php echo htmlspecialchars($Result['image']); ?>" class="img img-rounded" style="width:70px;"  /></br><?php echo htmlspecialchars($Result['model']); ?> / <p style="text-align: center;"><?php echo htmlspecialchars($Result['name']); ?> </br> <p style="text-align: right;"><?php echo number_format($Result['price'], 2, '.', ''); ?> лв.
          				
	<img src="<?php echo htmlspecialchars($Result['image']); ?>" class="img img-rounded" style="width:70px;"  /><?php echo htmlspecialchars($Result['name']); ?><br/><div class="address"><?php echo htmlspecialchars($Result['price']); ?> лв.</div>
           			  </div>
	           	   


	   <div class="panel-body">
          <div class="form-group">
		<div style="border:0.5px solid #ccc; border-radius:25px; padding:0px; margin-bottom:6px; height:200px;">
		<img src="'. $Result['image'] .'" style="width:70px; ">
	 
     <p align="center"><strong><a href="#">'. $Result['name'] .'</a></strong></p>
     <p style="text-align:bottom;" class="text-danger" ><strong>'. $Result['price'] .' лв.</strong> </p>
    </div>
	</div>
    </div>

   </div>
 ';
   </li></a>
 
   <!-- Below php code is just for closing parenthesis. Don't be confused. -->
 
   <?php
 
}}
 
 
?>
 
</ul>