<?php
if ( $_SERVER['REQUEST_METHOD']!='GET' && realpath(__FILE__) != realpath( $_SERVER['SCRIPT_FILENAME'] ) ) {
ini_set('memory_limit', '4095M');

$link = mysqli_connect("mysql4ward.mysql.database.azure.com", "fourwardmysql@mysql4ward", "@kirede!18#@", "db_convicto");




$resultadoTodoEstoque = $link->query("SELECT * FROM stock WHERE outletCvto > 0 ");

foreach ($resultadoTodoEstoque as $valueStock) {
    $resultadoEstoqueHas = $link->query("SELECT * FROM stockhasuserseller WHERE iduserseller = 1 and idstock = '" . $valueStock['id'] . "' and quantidade <> '" . $valueStock['outletCvto'] . "'");
    if ($resultadoEstoqueHas->num_rows < 0) {
        $stmt = $link->prepare("UPDATE stockhasuserseller SET quantidade='" . $valueStock['outletCvto'] . "' WHERE iduserseller=1 and idstock = '" . $valueStock['id'] . "'");
        $stmt->execute();
    }
}



}