Mam problem z wyświetlaniem polskich znaków. Mianowicie chodzi mi o to, że jeżeli występuje polski znak to albo wogóle nie wyświetla np. przy litrze "ó".
Pierwszy plik:
Kod
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery auto-complete, populate related fields</title>
<script type="text/javascript" src="jquery/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery/js/jquery-ui-1.8.2.custom.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
$('.zipsearch').autocomplete({
source:'jQueryAutocompleteRelatedFields.php',
minLength:1,
select:function(evt, ui)
{
// when a zipcode is selected, populate related fields in this form
this.form.nazwisko_u.value = ui.item.nazwisko_u;
this.form.login.value = ui.item.login;
}
});
});
</script>
<link rel="stylesheet" href="jquery/css/smoothness/jquery-ui-1.8.2.custom.css" />
<style type="text/css"><!--
/* style the auto-complete response */
li.ui-menu-item { font-size:12px !important; }
--></style>
</head>
<body>
<form onsubmit="return false;">
Podaj imię:
<input id="zipsearch" type="text" class="zipsearch" />
Nazwisko:
<input id="nazwisko_u" type="text" disabled />
Login:
<input id="login" type="text" disabled />
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery auto-complete, populate related fields</title>
<script type="text/javascript" src="jquery/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery/js/jquery-ui-1.8.2.custom.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
$('.zipsearch').autocomplete({
source:'jQueryAutocompleteRelatedFields.php',
minLength:1,
select:function(evt, ui)
{
// when a zipcode is selected, populate related fields in this form
this.form.nazwisko_u.value = ui.item.nazwisko_u;
this.form.login.value = ui.item.login;
}
});
});
</script>
<link rel="stylesheet" href="jquery/css/smoothness/jquery-ui-1.8.2.custom.css" />
<style type="text/css"><!--
/* style the auto-complete response */
li.ui-menu-item { font-size:12px !important; }
--></style>
</head>
<body>
<form onsubmit="return false;">
Podaj imię:
<input id="zipsearch" type="text" class="zipsearch" />
Nazwisko:
<input id="nazwisko_u" type="text" disabled />
Login:
<input id="login" type="text" disabled />
</form>
</body>
</html>
Plik drugi:
Kod
<?php
class DB
{
const DATABASE = 'przelewy';
const HOST = 'localhost';
const USERNAME = 'root';
const PASSWORD = '';
static private $pdo;
static public function singleton()
{
if (!is_object(self::$pdo))
{
self::$pdo = new PDO('mysql:dbname=' . self::DATABASE . ';host=' . self::HOST,
self::USERNAME,
self::PASSWORD);
}
return self::$pdo;
}
private function __construct()
{
}
public function __clone()
{
throw new Exception('You may not clone the DB instance');
}
}
if (!isset($_REQUEST['term']))
{
die('([])');
}
$st = DB::singleton()
->prepare(
'select imie_u, nazwisko_u, login ' .
'from uzytkownicy ' .
'where imie_u like :uzytkownicy ' .
'order by imie_u asc ' .
'limit 0,10');
$searchZip = $_REQUEST['term'] . '%';
$st->bindParam(':uzytkownicy', $searchZip, PDO::PARAM_STR);
$data = array();
if ($st->execute())
{
while ($row = $st->fetch(PDO::FETCH_OBJ))
{
$data[] = array(
'value' => $row->imie_u ,
'nazwisko_u' => $row->nazwisko_u ,
'login' => $row->login
);
}
}
echo json_encode($data);
flush();
class DB
{
const DATABASE = 'przelewy';
const HOST = 'localhost';
const USERNAME = 'root';
const PASSWORD = '';
static private $pdo;
static public function singleton()
{
if (!is_object(self::$pdo))
{
self::$pdo = new PDO('mysql:dbname=' . self::DATABASE . ';host=' . self::HOST,
self::USERNAME,
self::PASSWORD);
}
return self::$pdo;
}
private function __construct()
{
}
public function __clone()
{
throw new Exception('You may not clone the DB instance');
}
}
if (!isset($_REQUEST['term']))
{
die('([])');
}
$st = DB::singleton()
->prepare(
'select imie_u, nazwisko_u, login ' .
'from uzytkownicy ' .
'where imie_u like :uzytkownicy ' .
'order by imie_u asc ' .
'limit 0,10');
$searchZip = $_REQUEST['term'] . '%';
$st->bindParam(':uzytkownicy', $searchZip, PDO::PARAM_STR);
$data = array();
if ($st->execute())
{
while ($row = $st->fetch(PDO::FETCH_OBJ))
{
$data[] = array(
'value' => $row->imie_u ,
'nazwisko_u' => $row->nazwisko_u ,
'login' => $row->login
);
}
}
echo json_encode($data);
flush();
Dodam że w bazie metoda porównania napisów to: utf8_polish_ci.
Pliki są też kodowane utf-8.
Z góry dzięki za odpowiedź.