I've got a SQL script that "mounts" 3 tables, one with country, one with states, and one with Brazilian cities.
The script makes the collection
, of the names, in latin1_swedish_ci
and I needed it to be utf8_bin
, because the names with accent generates another character, and I still have to put those names in json
format. >
My HTML:
<div align="center">
<form>
<input type="hidden" ng-model="estado.idEstado">
Estado <input type="text" ng-model="estado.nome">
Sala <input type="text" ng-model="estado.sala">
<button ng-click="atualizarEstado(estado)">Atualizar</button><br>
</form>
My php:
<?php
include_once("conPDO.php");
$pdo = conectar();
$id = $_GET['idEstado'];
$buscarEstado=$pdo->prepare("SELECT * FROM estado WHERE idEstado=:id ");
$buscarEstado->bindValue(":id", $id);
$buscarEstado->execute();
//header('Content-Type: application/json');
$return = array();
while ($linha=$buscarEstado->fetch(PDO::FETCH_ASSOC)) {
$return = $linha;
print_r($return);
}
echo json_encode($return);
?>
On the console this appears:
Array
(
[idEstado] => 4
[nome] => Amap�
[uf] => AP
[pais] => 1
[sala] =>
)