<?php
session_start();


?>


<!DOCTYPE html>
<html lang="zxx" class="no-js">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Rahisi Enterprises</title>
    <!-- Favicon icon -->
    <link rel="icon" type="../quixlab/image/png" sizes="16x16" href="./quixlab/images/favicon.png">
    <!-- Pignose Calender -->
    <link href="../quixlab/plugins/pg-calendar/css/pignose.calendar.min.css" rel="stylesheet">
    <!-- Chartist -->
    <link rel="stylesheet" href="../quixlab/plugins/chartist/css/chartist.min.css">
    <link rel="stylesheet" href="../quixlab/plugins/chartist-plugin-tooltips/css/chartist-plugin-tooltip.css">
    <!-- Custom Stylesheet -->
    <link href="../quixlab/css/design.css" rel="stylesheet">
    <!-- DataTables with Buttons -->
    <link rel="stylesheet" href="../quixlab/plugins/tables/css/datatable/dataTables.bootstrap4.min.css">
    <link href="../quixlab/plugins/tables/css/datatable/dataTables.bootstrap4.min.css" rel="stylesheet">
    <link href="../quixlab/css/buttons.bootstrap.min.css" rel="stylesheet" />

</head>
<?php 
include_once 'shikanisha.kts.php';
// Check the connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
  

$output='';
$sql="SELECT * FROM products WHERE product_name LIKE'%".$_POST["search"]."%'";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result)>0){
 $output .= '<h4 align="center">Search result</h4>';
 $output .= '<div class="table-responsive">';
             ' <table class="table-bordered table-sm">       
                                       <thead>
                                            <tr>
                                                <th>Name</th>
                                                <th>Company</th>
                                                <th>Available</th>
                                                <th>Price</th>
                                                <th>Quantity</th>
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody>';
                                          while($row = mysqli_fetch_array($result)){
                                              echo'
                                              
                                    
                                              <tr class="table-bordered table-sm">
                                                  <form method="POST"> 
                                                    <td><input type="hidden" name="name" value='.$row['product_name'].' />'.$row['product_name'] .'</td>
                                                    <td> <input type="hidden" name="company" value='.$row['company'].' />'.$row['company'].'</td>
                                                    <td>'.$row['store_quantity'].'</td>
                                                    <td>'.$row['buying_price'].'</td>
                                                    
                                                   
												   
                                                    <td> <input type="number" class="form-control-sm" id="val-username" name="qty" placeholder="Enter qty"></td>
                                                    <td><button class="btn btn-success bg-success fa fa-shopping-cart btn-sm" type="submit" name="add" value='.$row['product_id'].'> Add to cart</button></td>
                                                  </form>
                                                </tr>
                                                
                                              ';
                                            

    }
   echo $output;
      
}
else{
    echo 'Data not found';
}
?>
