<?PHP
 require "conecta.php";
 require "funciones.php";
 $sql="select * from prov  ;";
 $res=mysql_query($sql,$con) or die(mysql_error());
 while ($fila=mysql_fetch_array($res)){//while 1
  $rut=purificatxt($fila[0]);
  if (strlen($rut)==8) {
   $rut="0" . $rut;
  }
  //$nom=$fila[1];
  //$dire=$fila[2];
  //$fono=$fila[3];
  //$com=$fila[5];
  //$ciu=$fila[7];
  $giro=$fila[8];
  echo $rut . "<br>";
  //$sqlg="replace into M02001 (rut,nombre,direccion,cod_comuna,telefono1,ciudad) 
  //values ('$rut','$nom','$dire','$com','$fono','$ciu');";
  $sqlg="update M02001 set giro='$giro' where rut='$rut';";
  $resg=mysql_query($sqlg,$con) or die(mysql_error());
  
 }//wend 1

//************************************************************
//************************************************************
//************************************************************

 //$sql="select * from prov ;";
 //$res=mysql_query($sql,$con) or die(mysql_error());
 //while ($fila=mysql_fetch_array($res)){//while 1
  //$rut=$fila[0];
  //$com=substr($fila[4],0,6);
  //$ciu=substr($fila[6],0,6);
  //$sqlc="select codcomu from m01003 where glosa like '%$com%';";
  //$resc=mysql_query($sqlc,$con) or die(mysql_error());
  //while ($filac=mysql_fetch_array($resc)){//while 2
   //$codcom=$filac[0];   
  //}//wend 2
  //$sqlc="select codcomu from m01003 where glosa like '%$ciu%';";
  //$resc=mysql_query($sqlc,$con) or die(mysql_error());
  //while ($filac=mysql_fetch_array($resc)){//while 2
   //$codciu=$filac[0];   
  //}//wend 2
  //$sqlg="update prov set cod_com='$codcom',cod_ciu='$codciu' where rut_prov='$rut';";
  //$resg=mysql_query($sqlg,$con) or die(mysql_error());
  //echo $codcom . "/" . $codciu . "/" . $com . "/" . $ciu . "<br>";
 //}//wend 1
 mysql_close($con);
?>