<?php
function sales_select_all($companyname, $emailid, $tablename, $deleted){
       
$host = 'localhost';
$db   = 'fieldclo_fieldclouddb';
$user = 'fieldclo_root321';
$pass = 'root@321';
$charset = 'utf8';

$dsn = "mysql:host=$host;dbname=$db;charset=$charset";

        $pdo=null;
$pdo = new PDO($dsn, $user, $pass, $opt);

if ($pdo->connect_error) {
	die("Connection failed: " . $pdo->connect_error);
}else{

echo "connected successfully";
}
        
        $em=$pdo->prepare('call sales_select_all("'.$companyname.'", "'.$emailid.'", "'.$tablename.'", "'.$deleted.'")');
        $em->execute();
        $pdo=null;
        return $em;
    }
    
    
$response = array();
// check for post data
if (isset($_GET["companyname"])  ) {
    $companyname = $_GET['companyname'];
    
    
    
    $result=sales_select_all("Webtech sales", "velemailid@gmail.com", "sales_contact_title", "no");
    $cc=$result->rowCount();
    if($cc>0){
        $response["sales_contact_title"] = array();
        foreach($result as $row_title)
        {
        echo  "<br>".$c_name=$row_title['contacttitle_name'];
        
        $sales_contact_title= array();
        
        $sales_contact_title["contacttitle_name"] =$row_title['contacttitle_name'];
        
        
        
        array_push($response["sales_contact_title"], $sales_contact_title);
        }
        // success
        $response["success"] = 1;            // echoing JSON response
        echo json_encode($response);
    }else {
        // no product found
        $response["success"] = 0;
        $response["message"] = "No product found";
        
        // echo no users JSON
        echo json_encode($response);
    }
   
}else {
    // no product found
    $response["success"] = 2;
    $response["message"] = "input data error";
    
    // echo no users JSON
    echo json_encode($response);

}
?>