Answer the question
In order to leave comments, you need to log in
How to display XML tag attributes via $_GET?
Hello.
There is an XML file on a third-party service, I read it and form it based on it.
// Municipal unions
$xmlfile = "http://178.211.1.214/gkh/WS/RestService.svc/GetRaionList";
$xml = simplexml_load_file($xmlfile);
$munUnion = $xml->MunicipalUnions->MunicipalUnion;
print '<form action="mkd.php" method="GET">';
print '<p><select name="munUnions">'; // TODO name="munUnions" AS ARRAY name="munUnions[]"
print '<option disabled selected>Выберите район\поселение</option>';
foreach($munUnion as $val) {
$muName = $val['Name']; // Имя района
$muUnionId = $val['Id']; // ID района
$typeMU = $val['TypeMU']; // Тип муниципального образования
// TODO Refactor to function
// If currrent munUnion equals chosen add selected
if($_GET['munUnions'] == $muUnionId) {
$selected = ' selected ';
} else {
$selected = ' ';
}
print '<option'.$selected.$disabled.'value="'.$muUnionId.'">'.$muName.' ('.$typeMU.')</option>';
}
print '</select></p>';
print '<p><input type="submit" name="SubmitMununion" value="Get cities List" /></p>
</form>';
// END Municipal unions
$_GET['munUnions']
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question