<?php

    $request_json=$_REQUEST["data"];
    $arr = json_decode($request_json, true);
    $filterValue = $arr["filterValue"];
    $filterType = $arr["filterType"];
    //include 'common/connection.php';
    $servername = "localhost";
    $username = "finstech_sales";
    $password = "SalesApp@123";
    $dbname = "finstech_salesapp";
    
    
    try {
        $conn = mysqli_connect($servername,$username,$password,$dbname);
        if(!$conn)
        {
            trigger_error('Could not Connect' .mysqli_connect_error());
        }
        if($filterType == "category"){
        $sql = "select shop_id,shop_name,pincode,place,category,mobile from master_shop where category='$filterValue' ";
        }
        if($filterType == "pincode"){
        $sql = "select shop_id,shop_name,pincode,place,category,mobile from master_shop where pincode='$filterValue' ";
        }
        $result = mysqli_query($conn, $sql);
        $array = array();
        while($row=mysqli_fetch_assoc($result))
        {
            $array[] = $row;
        }
        echo'{"shops":'.json_encode($array).'}'; 
        $conn = null;
    }catch(PDOException $e) {
        echo $sql . "err" . $e->getMessage();
    }
    $pdo = null;
    
?>