- Регистрация
- 5 Окт 2007
- Сообщения
- 1.064
- Реакции
- 200
- Автор темы
- Заблокирован
- #1
Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
header('Content-Type: text/plain; charset=utf-8');
$conn = mysql_connect("localhost","root","");
mysql_select_db("test",$conn);
mysql_query("SET NAMES 'utf8'");
if(isset($_GET['getCountriesByLetters']) && isset($_GET['letters'])){
$letters = $_GET['letters'];
$letters = preg_replace("/[^a-zа-яё0-9 ]/si","",$letters);
$res = mysql_query("select ID,countryName from ajax_countries where countryName like '".mysql_real_escape_string($letters)."%'") or die(mysql_error());
//echo "1###select ID,countryName from ajax_countries where countryName like '".$letters."%'|";
while($inf = mysql_fetch_array($res)){
echo $inf["ID"]."###".$inf["countryName"]."|";
}
}
тут для utf-8 файл ajax-list-countries.php, добавлена кодировка и исправлена регулярка
а альтернативы например дополнения для jqueryPHP:header('Content-Type: text/plain; charset=utf-8'); $conn = mysql_connect("localhost","root",""); mysql_select_db("test",$conn); mysql_query("SET NAMES 'utf8'"); if(isset($_GET['getCountriesByLetters']) && isset($_GET['letters'])){ $letters = $_GET['letters']; $letters = preg_replace("/[^a-zа-яё0-9 ]/si","",$letters); $res = mysql_query("select ID,countryName from ajax_countries where countryName like '".mysql_real_escape_string($letters)."%'") or die(mysql_error()); //echo "1###select ID,countryName from ajax_countries where countryName like '".$letters."%'|"; while($inf = mysql_fetch_array($res)){ echo $inf["ID"]."###".$inf["countryName"]."|"; } }
*** скрытое содержание ***
или без jquery
*** скрытое содержание ***
var url = ajax_list_externalFile + '?' + paramToExternalFile + '=1&letters=' + inputObj.value.replace(" ","+");
var url = ajax_list_externalFile + '?' + paramToExternalFile + '=1&letters=' + encodeURIComponent(inputObj.value);
header('Content-Type: text/plain; charset=windows-1251');
$conn = mysql_connect("localhost","root","");
mysql_select_db("test",$conn);
mysql_query("SET NAMES 'cp1251'");
if(isset($_GET['getCountriesByLetters']) && isset($_GET['letters'])){
$letters = iconv('UTF-8', 'Windows-1251', $_GET['letters']);
$letters = preg_replace("/[^a-zа-яё0-9 ]/si","",$letters);
$res = mysql_query("select ID,countryName from ajax_countries2 where countryName like '".mysql_real_escape_string($letters)."%'") or die(mysql_error());
//echo "1###select ID,countryName from ajax_countries where countryName like '".$letters."%'|";
while($inf = mysql_fetch_array($res)){
echo $inf["ID"]."###".$inf["countryName"]."|";
}
}
//echo "1###select ID,countryName from ajax_countries where countryName like '".$letters."%'|";
$letters = preg_replace("/[^a-zа-яё0-9 ]/si","",$letters);