<?php



$con = mysqli_connect('localhost','dotrazie_new','catalonia9f532','dotrazie_new');


if(!$con){
    die("couldnt connect".mysqli_error);
}


$result = mysqli_query($con,"SELECT c.ID, c.Name, c.Customer, c.Technologies, p.ImageType, p.Path FROM customers c LEFT JOIN pictures p ON p.IDCustomer = c.ID");
//$result = mysqli_query($con,"SELECT * FROM customers");

//$query = "SELECT * FROM customers";
//$result = $con->query($query);
$arr = array(array());

//$arr = ["a","b","c"]["1","2","3"];

$asd = array();

$asd = ["a","b","c"];

echo $asd[0];

$arr[0][0] = "a";
$arr[0][1] = "1";
$arr[1][0] = "b";
$arr[1][1] = "2";



$test = array();
$testPush = array();

$testPush = ["desk1","desk2"];
$test = ["asd","bca"];

$testPush["desk1"] = array();
array_push($testPush["desk1"], $test);
//echo $test["name"][0];


echo "<pre>";
print_r($test);
print_r($testPush);
echo "/<pre>";

$res123 =  json_encode($testPush);

echo "TestNew:<br>";

echo $res123;





$r = array();
if( $result->num_rows>0){
    while($row = $result->fetch_assoc()){
        $r[] = $row;
        if ($row["ID"] == 1) {
            echo "TRIGGER";
        }

        array_push($arr,$r);

        //array_splice( $original, 3, 0, $inserted ); // splice in at position 3
        //$r["Name"] = "aaaaa";
        //$r = array_merge($r,)

        //$r = array_splice( $original, 3, 0, $inserted ); // splice in at position 3


    }
}
//$res = json_encode($r);

//$r = array_splice( $r, "2,2", "0,0", $arr ); // splice in at position 3

//echo array for debbuging
echo "<pre>";
print_r($r);
echo "/<pre>";




$res_arr_values = array(array());
$res_arr_values[0][0] = "Desktop";
$res_arr_values[0][1] = "desk1";
$res_arr_values[0][2] = "desk2";

//$res_arr_values[1][0] = "Desktop";
//$res_arr_values[1][1] = "desk2";


//while ($row = mysqli_fetch_assoc($r))
//{
//    $res_arr_values[] = $row;
//}


$merge = array_merge($r, $res_arr_values);


echo "<pre>MERGE";
print_r($merge);
echo "/<pre>";


$output = mysqli_fetch_all($result,MYSQLI_ASSOC);
echo "TEST:". json_encode($output);

echo "<br>";



$json_array = json_decode(json_encode($r), true);

echo "ARR:".$json_array[1]["Name"]."<br>";

$res = json_encode($r);



//header('Content-Type: application/json');
echo $res;
echo "<br/>";
echo "<br/>";
echo "<br/>";
echo "<br/>";
echo "<br/>";
echo $r[0];
echo "<br/>";
echo "<br/>";
echo "<br/>";
echo $result[0];




//$r = array();


//$r = "asd";
//
//$res = json_encode($r);
//header('Content-Type: application/json');
//echo $res;


//echo "raziel";


?>