api – Change of status in PHP

I am making a api change the status of an article in an inventory, for some process, the change can be applied.

else if (isset ($ _ POST['id']) && isset ($ _ POST)['x']))
{

$ connection = new MySqlServerConnection ();

$ query1 = SELECT quantity-2, reorder_Level FROMventary_list WHERE id =? ;;
$ result1 = $ connection-> executeQuery ($ query1, array ($ _ POST['id']));
echo $ result1[0][0];
echo $ result1[0][1];

if (intval ($ result1[0][0]) = intval ($ result1[0][1]))
{
$ query = UPDATE inventory_list SET status = 2 WHERE id =? ;;
$ result = $ connection-> executeNonQueryWithReturn ($ query, array ($ _ POST['id']));
}
if not
{
$ query = UPDATE Supplies SET status = 1 WHERE id =? & # 39 ;;
$ result = $ connection-> executeNonQueryWithReturn ($ query, array ($ _ POST['id']));
}
if ($ result == 1)
{
echo json_encode (array (
& # 39; status & # 39; => & # 39; 0 & # 39;
& # 39; errorMessage & # 39; => & # 39; change status of article & # 39;
));
}
if not
{
echo json_encode (array (
& # 39; status & # 39; => & # 39; 2 & # 39;
& # 39; errorMessage & # 39; => & # 39; article does not change the status & # 39;
));
}
}

else if (isset ($ _ POST['id']))
{

$ connection = new MySqlServerConnection ();
$ query1 = 'SELECT quantity', reorder_Level FROM Inventorylist WHERE id =? ';;
$ result1 = $ connection-> executeQuery ($ query1, array ($ _ POST['id']));

if (intval ($ result1[0][0]) <= intval($result1[0][1]))
        	{
              $query = 'UPDATE inventory_list SET status = 3 WHERE  id = ?';
              $result = $connection >executeNonQuery ($ query, array ($ _ POST['id']));
}
if not
{
$ query = UPDATE inventory_list SET status = 0 WHERE id =? ;;
$ result = $ connection-> executeNonQuery ($ query, array ($ _ POST['id']));
}

if ($ result == 0)
{
echo json_encode (array (
& # 39; status & # 39; => & # 39; 0 & # 39;
& # 39; errorMessage & # 39; => & # 39; change status of article & # 39;
));
}
if not
{
echo json_encode (array (
& # 39; status & # 39; => & # 39; 2 & # 39;
& # 39; errorMessage & # 39; => & # 39; article does not change the status & # 39;
));
}

}

This is based on amount and reorder_level (minimum amount)in the first query, I try to change it to status 2 If my current quantity is about to end with a difference in 2that's why he left this amount from the beginning.

Example: If my reorder_level it's from 2 and my current quantity is 4, subtracting 2 from the beginning this would be equal to my minimum quantity in stock so there is a difference 2 so that's over, and change the status to 2.
Otherwise, go to status 1.

In the next else if If my quantity is equal to or less than my reorder_level then change to status 3because it is below the minimum, otherwise it goes to status 0

0 = the article is inactive.

1 = the article is active.

2 = the article is about to end.

3 = the item is below its minimum.

In the code gives no error, executes but does not perform the function, does not change status, the intermediate processes may be that they add more units to amount or take off. He is there when you run the api.