<?php  
ob_start();
session_start();
include("fresh_panel/inc/config.php");
 
 if(isset($_POST['dt'])){
$reg_no=$_POST['dt'];

$statement9 = $pdo->prepare("SELECT * FROM tbl_country WHERE state_id=?");
$statement9->execute(array($reg_no));
$result9 = $statement9->fetchAll(PDO::FETCH_ASSOC);  ?>
<option value="">Select District</option>
<?php
foreach ($result9 as $row) {
  ?>
    
<option value="<?php echo $row['country_name']; ?>"><?php echo $row['country_name']; ?></option> 
   
<?php }
}




if(isset($_POST['pin_code'])){
    $pin_code=$_POST['pin_code'];

$statement9 = $pdo->prepare("SELECT pin FROM `pin` WHERE `pin` = ? AND `status` = ? ");
$statement9->execute(array($pin_code,0));
$rowCount = $statement9->rowCount();
$stmt_row = $statement9->fetchColumn(); 
if($rowCount===1){
$_SESSION['pin_code']=$stmt_row;
}
// response for user
    $myObj->pin_count = $rowCount;
    $myObj->pin_code = $stmt_row;
    
    $myJSON = json_encode($myObj);
    
    echo $myJSON;
    
}


if(isset($_POST['keyword'])){
    $KEYWORD = $_POST['keyword'];
    $statement9 = $pdo->prepare("SELECT * FROM `tbl_product` WHERE `p_name` LIKE ? ");
$statement9->execute(array("%$KEYWORD%"));
$rowCount = $statement9->rowCount();
$result9 = $statement9->fetchAll(PDO::FETCH_ASSOC);
if($rowCount){
    ?>
    <ul id="country-list">
<?php
foreach($result9 as $product) {
?>
<li onClick="selectCountry('<?php echo $product["p_name"]; ?>');"><a href="search-result.php?search_text=<?php echo $product["p_name"]; ?>"><?php echo $product["p_name"]; ?></a></li>
<?php }
}

?>
</ul>
<?php
}




?>