<?php 
    include("../db.php");
    $ch=$_REQUEST["type"];
    $id=$_REQUEST["id"];
    if($ch=='edit'){
        $data = $db->getRow("select * from facilities where id=$id ");
        echo json_encode($data);  
    }
    
    if($ch=='update'){
        
        $id=$_REQUEST["id"];
        $service=$_REQUEST["service"];
        $desc=$_REQUEST["desc"];
        $pic=$_REQUEST["pic"];
        
        if($pic==""){
             $insAry=array( 
                "service"=>$service,
				"description"=>$desc,
								 
						);
             $inup=$db->updateAry("facilities",$insAry,"where id='$id'"); 
        }
        else{
          $file = addslashes(file_get_contents($_FILES["image"]["tmp_name"]));
            $insAry=array( 
                "service"=>$service,
				"description"=>$desc,
								 	"image"=>$file,
						);
						print_r($file);
						die();
            $inup=$db->updateAry("facilities",$insAry,"where id='$id'"); 
        }
     
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ?>