1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
<?php
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
include('../01_scripts/connexion.php');
include('../01_scripts/lib.php');
echo "<list>";
$codePostal = (isset($_POST["cp"])) ? htmlentities($_POST["cp"]) : NULL;
if ($codePostal) {
$departementNumero = substr($codePostal,0,-3);
$sql = "SELECT departementId,departementLibelle,departementNumero FROM gp_departements WHERE departementNumero = '$departementNumero'";
$req = $db->prepare($sql);
$req->bindValue(':departementNumero', $departementNumero,PDO::PARAM_INT);
$req->execute();
$r = $req->fetch();
$departementId=$r['departementId'];
$departementLibelle=$r['departementLibelle'];
while ($r = $req->fetch()) {
// echo "<item id=\"" . $back["id"] . "\" name=\"" . $back["name"] . "\" />";
echo "<item departementId=\"" . $r["departementId"] . "\" departementLibelle=\"" . $r["departementLibelle"] . "\" />";
}
}
echo "</list>";
?> |
Partager