<?php

error_reporting(E_ERROR | E_PARSE);
// sql data connection 
$DB_Host = "localhost";
$DB_Name = "mrcode_FMdatabase";
$DB_Table = "MOOBOQ";
$DB_User = "mrcode_User";
$DB_Pass = "o;1fT@L+cB&P";

//Get data from Mobile app

//$username = $_GET['username'];
$urn =$_GET['urn'];
$myArray = array();

    
    // connect to sql 
    
    $conn = new mysqli($DB_Host, $DB_User, $DB_Pass,$DB_Name);
    
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
        
    } 

$sql = "SELECT * FROM `MOOBOQ` WHERE urn = '". $urn ."'" ;

$result = $conn->query($sql);

if ($result->num_rows > 0) {
    
    while($row = $result->fetch_assoc()) {
        $myArray[] = $row;
    }
    
    $myJSON = json_encode(array('BOQs' => $myArray));
    
    echo $myJSON;
    
}

else{
    
    $myObj->BOQ = null;
    
    $myArray[] = $myObj;
    
    $myJSON = json_encode(array('BOQs' =>$myArray));
    
    echo $myJSON;

}

$conn->close();


?>
