Bonjour,
sur une page php j'utilise une table région, qui selon la région va m'afficher les départements liés à celui-ci.
Mais petit soucis, dans la bdd ceux ci sont écrit correctement, mais lors de l'affichage ya un probleme d'encodage que je n'arrive pas à résoudre.
Premièrement sur la page php, dont j'ai bien mis dans le head l'encodage :
<label>Régions</label>
<select id="reg" onchange="request(this);">
<option value="none">Selection</option>
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=mastermarketing', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$query = $bdd->query("SELECT * FROM regions ORDER BY nom");
while ($back =$query->fetch()) {
echo "\t\t\t\t<option value=\"" . $back["num_region"] . "\">" . $back["nom"] . "</option>\n";
}
?>
</select>
============================================
Et ensuite dans la page qui va rechercher les régions :
<?php
header("Content-Type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo "<list>";
$loc = (isset($_POST["localisation"])) ? htmlentities($_POST["localisation"]) : NULL;
if ($loc) {
try
{
$bdd = new PDO('mysql:host=localhost;dbname=mastermarketing', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$query = $bdd->query("SELECT * FROM departements WHERE num_region=" . mysql_real_escape_string($loc) . " ORDER BY nom");
while ($back = $query->fetch()) {
echo "<item id=\"" . $back["nom"] . "\" name=\"" . $back["nom"] . "\" />";
}
}
echo "</list>";
?>
La ça m'étonne vraiment car come vous pouvez voir j'ai précisé encoding uft8 donc je ne vois pas pourquoi çe ne marche pas...
Afficher la suite