$check_stock = Stock::check($id); //check product - on any stock $res = mysqli_fetch_array($check_stock); $info_array = array(); //array for sending multiple data by json to SavaScript if ($res['storehouse_id'] == $storehouse_id) { //if true - the goods already on this stock $info_f = 'This product is on this stock'; $info_array[] = $info_f; //put the information into an array to send by json echo json_encode($info_array); //send json data to JavaScript } else { $change_stock = Stock::change_stock($id, $storehouse_id); //change the id warehouse $change_stock_product = Product::change_stock($id, $storehouse_id); //change the id warehouse if ($change_stock == TRUE && $change_stock_product == TRUE) { $warehouse_name = Storehouse::getStorehouse($storehouse_id); //get the name of the warehouse to display to the user from JavaScript $warehouse_name = mysqli_fetch_array($warehouse_name); $info = 'Product successfully transferred'; $info_array[] = $info; //put the information into an array to send by json $info_array[] = $warehouse_name['name']; //put the information into an array to send by json echo json_encode($info_array); //send json data to JavaScript } else { $info_d = 'Please try again'; $info_array[] = $info_d;