<?PHP
 require "conecta.php";
 $sql="select * from m07005;";
 $res=mysql_query($sql,$con);
 while ($fila=mysql_fetch_row($res)){
  $cod=$fila[0];
  $stock=$fila[2];
  //echo $stock ."<br>";
  $sql2="select * from m070052 where cod_interno='$cod';";
  $res2=mysql_query($sql2,$con);
  if (mysql_num_rows($res2)==0){   
   $sqli="insert into m070052 (cod_interno,stockcc,cod_local,stock) values ('$cod','$stock','01','0');";
   $resi=mysql_query($sqli,$con) or die(mysql_error());
   }else{
    $sqli="update m070052 set stockcc='$stock' where cod_interno='$cod';";
	$resi=mysql_query($sqli,$con) or die(mysql_error());
	$cont++;
   }  
 }
 echo $cont;
?>
