$resortR = mysql_query("SELECT * FROM countryresort WHERE gismeteo!='' ");
$resort = mysql_fetch_array($resortR);
do{
$res[$resort['id']]['id'] = $resort['id'];
$res[$resort['id']]['gismeteo'] = $resort['gismeteo'];
}while($resort = mysql_fetch_array($resortR));
foreach($res as $key => $value){
$xmlurl = 'http://informer.gismeteo.ru/xml/'.$value['gismeteo'].'_1.xml';
$xml = simplexml_load_file(rawurlencode($xmlurl));
$town_index = $xml->REPORT->TOWN->attributes()->index;
$town_sname = $xml->REPORT->TOWN->attributes()->sname;
$town_latitude = $xml->REPORT->TOWN->attributes()->latitude;
$town_longitude = $xml->REPORT->TOWN->attributes()->longitude;
for($i=0;$i<=3;$i++){
$forecast_day = $xml->REPORT->TOWN->FORECAST[$i]->attributes()->day;
$forecast_month = $xml->REPORT->TOWN->FORECAST[$i]->attributes()->month;
$forecast_year = $xml->REPORT->TOWN->FORECAST[$i]->attributes()->year;
$forecast_hour = $xml->REPORT->TOWN->FORECAST[$i]->attributes()->hour;
$forecast_date = $forecast_year.'-'.$forecast_month.'-'.$forecast_day.' '.$forecast_hour.':00:00';
$forecast_tod = $xml->REPORT->TOWN->FORECAST[$i]->attributes()->tod;
$forecast_predict = $xml->REPORT->TOWN->FORECAST[$i]->attributes()->predict;
$forecast_weekday = $xml->REPORT->TOWN->FORECAST[$i]->attributes()->weekday;
$phenomena_cloudiness = $xml->REPORT->TOWN->FORECAST[$i]->PHENOMENA->attributes()->cloudiness;
$phenomena_precipitation = $xml->REPORT->TOWN->FORECAST[$i]->PHENOMENA->attributes()->precipitation;
$phenomena_rpower = $xml->REPORT->TOWN->FORECAST[$i]->PHENOMENA->attributes()->rpower;
$phenomena_spower = $xml->REPORT->TOWN->FORECAST[$i]->PHENOMENA->attributes()->spower;
$pressure_min = $xml->REPORT->TOWN->FORECAST[$i]->PRESSURE->attributes()->min;
$pressure_max = $xml->REPORT->TOWN->FORECAST[$i]->PRESSURE->attributes()->max;
$temperature_min = $xml->REPORT->TOWN->FORECAST[$i]->TEMPERATURE->attributes()->min;
$temperature_max = $xml->REPORT->TOWN->FORECAST[$i]->TEMPERATURE->attributes()->max;
$wind_min = $xml->REPORT->TOWN->FORECAST[$i]->WIND->attributes()->min;
$wind_max = $xml->REPORT->TOWN->FORECAST[$i]->WIND->attributes()->max;
$wind_direction = $xml->REPORT->TOWN->FORECAST[$i]->WIND->attributes()->direction;
$relwet_min = $xml->REPORT->TOWN->FORECAST[$i]->RELWET->attributes()->min;
$relwet_max = $xml->REPORT->TOWN->FORECAST[$i]->RELWET->attributes()->max;
$heat_min = $xml->REPORT->TOWN->FORECAST[$i]->HEAT->attributes()->min;
$heat_max = $xml->REPORT->TOWN->FORECAST[$i]->HEAT->attributes()->max;
mysql_query ("INSERT INTO gismeteo SET
idresort='{$value['id']}',
town_index='$town_index',
town_sname='$town_sname',
town_latitude='$town_latitude',
town_longitude='$town_longitude',
forecast_date='$forecast_date',
forecast_tod='$forecast_tod',
forecast_predict='$forecast_predict',
forecast_weekday='$forecast_weekday',
phenomena_cloudiness='$phenomena_cloudiness',
phenomena_precipitation='$phenomena_precipitation',
phenomena_rpower='$phenomena_rpower',
phenomena_spower='$phenomena_spower',
pressure_min='$pressure_min',
pressure_max='$pressure_max',
temperature_min='$temperature_min',
temperature_max='$temperature_max',
wind_min='$wind_min',
wind_max='$wind_max',
wind_direction='$wind_direction',
relwet_min='$relwet_min',
relwet_max='$relwet_max',
heat_min='$heat_min',
heat_max='$heat_max'
");
}
}