<?php

/* $Id: SelectCustomer.php 7133 2015-02-07 03:23:51Z daintree $*/

//include('includes/session.inc');
//$Title = _('HRMS');
//include('includes/header.inc');
//include('includes/SQL_CommonFunctions.inc');
//echo '<link href="' . $RootPath . '/css/evergreen2'.'/default.css" rel="stylesheet" type="text/css" media="screen"/>';

      

//check.php  

$connect = new mysqli("localhost", "sooggoo", "4Compassion*", "evergreenint"); 


//
$request = $_POST['request']; // request

// Get username list
if($request == 1){
 $search = $_POST['search'];

 $query = "SELECT stockid,description FROM stockmaster WHERE description like'%".$search."%'";
 $result = mysqli_query($connect,$query);  
 
 while($row = mysqli_fetch_array($result) ){
  $response[] = array("value"=>$row['stockid'],"label"=>$row['description']);
 }

 // encoding array to json format
 echo json_encode($response);
 exit;
}

// Get details
if($request == 2){
 $stockid = $_POST['stockid'];
 $sql1 = "SELECT stockid,price FROM prices WHERE stockid='".$stockid."'";

 $result = mysqli_query($connect,$sql1); 

 $users_arr = array();

 while( $row = mysqli_fetch_array($result) ){
   $stockid = $row['stockid'];
  $price = $row['price'];

  $users_arr[] = array("stockid" =>$stockid,"price" =>$price);
 }

 // encoding array to json format
 echo json_encode($users_arr);
 exit;
}

?>

