-1

这是 search.js 中的代码`

$('#search').keyup(function () {
var search_term = $(this).val();
$.post('search1.php', { search_term: search_term }, function(data) {
    $('#search_results').html(data);
    })

; });`

我在 phpmyadmin 中使用 utf_8 和

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-6">

在 html 代码中

这是search.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-6">
<head>
        <meta charset="utf-8">
        <title>search</title>
        <link rel="stylesheet" type="text/css" href="css/style5.css">
</head>
<body>
       search name : <input id="search" type="text" />
        <div id="search_results"></div>
        <script type="text/javascript" src="js/jquery.js" ></script>
        <script type="text/javascript" src="js/search.js" ></script>

</body>
</html>

这是search1.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-6">
<head>
<meta charset="utf-8">
<title>search</title>
</head>
<body>
<?php
include('connect.php');
if (isset($_POST['search_term'])) {
$search_term = mysql_real_escape_string(htmlentities($_POST['search_term']));
if (!empty($search_term)) {

$search= mysql_query("SELECT name FROM patients WHERE name like '%$search_term%'");
$result_count = mysql_num_rows($search);
$suffix = ($result_count !=1) ? 's' : '';
echo '<p>your search for '.$search_term.' returned '.$result_count.'result'.$suffix.'</p>';
while ($results_row = mysql_fetch_assoc($search)){

echo '<P><strong>'.$results_row['name'].'</strong></p>';


}
}
}

?>
</body>
</html>

当我在框中写“ع”时,我会显示“ع”

4

1 回答 1

0

UTF-8不是iso-8859-6。您应该将字符集设置为 UTF-8,或者将 MySQL 输出转换为 iso-8859-6。

于 2012-09-28T03:14:16.130 回答