SELECT * FROM winners ORDER BY win_date DESC LIMIT 0, 5
$query = mysql_query("SELECT * FROM `$table` SORT BY street, house_number, app_number ");
// Затем в цикле разбираем запрос, и формируем XML
$xml = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL;
$prev_street = null;
$prev_house = null;
$prev_app = null;
$prev_acc = null;
while ($row = mysql_fetch_array($query)) {
if ($prev_acc != null && $row['account'] != $prev_acc) {
$xml .= '</account>' . PHP_EOL;
}
if ($prev_app != null && $row['app_number'] != $prev_app) {
$xml .= '</apartment>' . PHP_EOL;
}
if ($prev_house != null && $row['house_number'] != $prev_house) {
$xml .= '</house>' . PHP_EOL;
}
if ($prev_street != null && $row['street'] != $prev_street) {
$xml .= '</street>' . PHP_EOL;
}
if ($row['street'] != $prev_street) {
$xml .= '<street name="' . $row['street'] . '">' . PHP_EOL;
$prev_street = $row['street'];
}
if ($row['house_number'] != $prev_house) {
$xml .= '<house number="' . $row['house_number'] . '">' . PHP_EOL;
$prev_house = $row['house_number'];
}
if ($row['app_number'] != $prev_app) {
$xml .= '<apartment number="' . $row['app_number'] . '">' . PHP_EOL;
$prev_app = $row['app_number'];
}
if ($row['account'] != $prev_acc) {
$xml .= '<account id="' . $row['account'] . '" person="">' . PHP_EOL;
$prev_acc = $row['account'];
}
$xml .= '<device id="' . $row['device_id'] . '" value="' . $row['new_meterage'] . '" date="дата" type="1"/>' . PHP_EOL;
}
$xml .= '</account>' . PHP_EOL . '</apartment>' . PHP_EOL . '</house>' . PHP_EOL . '</street>';
echo $xml;
foreach($_POST["pokazaniya"] as $key=>$value) {
//в $value - показания
}
while ($data = mysql_fetch_array($qr_result)) {
echo '<tr>';
echo '<td><input type="text" name="devices['.$data['device_id'].'][street]" value="' . $data['street'] . '" maxlength="10" form="myform" disabled></td>';
echo '<td><input type="text" name="devices['.$data['device_id'].'][house_number]" value="' . $data['house_number'] . '" maxlength="10" form="myform" disabled></td>';
echo '<td><input type="text" name="devices['.$data['device_id'].'][appartment_number]" value="' . $data['app_number'] . '" maxlength="10" form="myform" disabled></td>';
echo '<td><input type="text" name="devices['.$data['device_id'].'][device_id]" value="' . $data['device_id'] . '" maxlength="10" form="myform" disabled></td></td>';
echo '<td><input type="text" name="devices['.$data['device_id'].'][description]" value="' . $data['description'] . '" maxlength="10" form="myform" disabled></td>';
echo '<td><input type="number" name="devices['.$data['device_id'].'][old_meterage]" value="' . $data['old_meterage'] . '" maxlength="10" form="myform" disabled></td>';
echo '<td><input type="text" name="devices['.$data['device_id'].'][new_meterage]" maxlength="10" form="myform"></td></tr>';
}
$_POST = [
'devices' =>
[
'1234567' => //<--ID счётчика
[
'street' => '',
'house_number' => '',
'appartment_number' => '',
'device_id' => '',
'description' => '',
'old_meterage' => '',
'new_meterage' => '',
]
]
]
foreach($_POST['devices'] as $device_id=>$device_data) {
// В переменной $device_id - айдишник вашего прибора учёта.
// В переменной $device_data - все поля формы для этого конкретного прибора
}
SELECT p.post, u.nickname FROM users as u, posts as p WHERE u.id = p.id_user;
foreach($sxml->location->street as $street) {
foreach($street->house as $house) { //Перебираем дома только на текущей улице
$house_number = stripslashes($house->apartment->attributes()['number']);
echo "<br>'$house_number'";
$app_number = stripslashes($house->attributes()['number']);
echo "_'$app_number'";
$id = ($house->apartment->account->attributes()['id']);
echo "_'$id'";
}
}
$raw_uri = $_SERVER['REQUEST_URI'];
$uri_map = array(
'/region/section/13' => '/region/section/kuhonnaja-mebel',
);
if (count($_GET)) {
$tmp_uri = explode('?', $raw_uri);
$uri['address'] = strtolower($tmp_uri[0]);
$uri['request'] = '?' . $tmp_uri[1];
} else {
$uri['address'] = strtolower($raw_uri);
$uri['request'] = '';
}
if (isset($uri_map[$uri['address']])) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://' . $_SERVER['HTTP_HOST'] . $uri_map[$uri['address']] . $uri['request']);
exit;
}