<?php 
include 'dbconfig.php';
 
// Create connection

$printer=$_POST['printer'];
$tipe=$_POST['tipe'];

//echo $notrans;
 
$conn = mysqli_connect($servername, $username, $password, $dbname);
 
// Check connection
 
if (!$conn) {
 
    die("Connection failed: " . mysqli_connect_error());
 
}


if ($tipe=='1')
{

$sql ="update tbprint set printer='$printer'" ;
$res = mysqli_query($conn, $sql);

$response = mysqli_query($conn, $sql) or die('Error query:  '.$sql);
 
 $result["message"]="ok";
 
if ($response == 1){
    echo json_encode($result);
}

}

if ($tipe=='2')
{
$sql ="select printer from  tbprint" ;
$res = mysqli_query($conn, $sql);
$res2=mysqli_fetch_row($res);
$res21=$res2[0];
$result['data']=$res21;
echo json_encode($result);
}

 mysqli_close($conn);
?>