php - 在 MYSQL 中搜索具有西类牙口音的圣经网站字符集

标签 php html mysql css character-encoding

我将运行一个圣经网站,因此我使用 MYSQL 默认字符集 latin1_swedish_ci 创建了数据库,但该网站将使用西类牙语。

问题是创世记使用重音符号,Éxodo 和 Josué 也是,所以当人们搜索例如:

$getbook = $_GET['L'];
$bible = mysqli_query($database, "SELECT * FROM `bible` WHERE `book` LIKE '%$getbook%'");

如果人们搜索不带口音的 Genesis,则会有结果,但如果人们搜索带口音的 Génesis,则不会有任何结果。

这是我显示结果的脚本:

<?php
$server = 'localhost';$user = 'username';$pass = 'password';$source = 'this';
$database = @mysqli_connect ($server, $user, $pass, $source) OR die ('Could not connect to MySQL: ' . mysqli_connect_error());
header ('Content-type: text/html; charset=iso-8859-15');
$getbook = $_GET['L'];
$bible = mysqli_query($database, "SELECT * FROM `bible` WHERE `book` LIKE '%$getbook%'");
while($show = mysqli_fetch_assoc($bible)) {
?>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15">

<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10%">Chapter</td>
    <td width="10%">Verse</td>
    <td width="80%">Text</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10%"><?php echo $show['chapter'] ?></td>
    <td width="10%"><?php echo $show['verse'] ?></td>
    <td width="80%"><?php echo $show['text'] ?></td>
  </tr>
</table>
<?php
}
?>  

结果文本还可以,唯一的问题是当您使用重音符号进行搜索时。它显示 Genesis 的结果,但不显示带重音的 Génesis 的结果。

这是要测试的真实站点:

WITH ACCENT:
http://santabiblia.cl/?L=Génesis 
no results

WITHOUT ACCENT:
http://santabiblia.cl/?L=Genesis 
Yes we have results

有什么想法吗?

编辑

数据库看起来像

数据库名称 圣经 -> 书 - 章 - 节 - 正文

例子

book = Génesis(带口音)chapter = 1 verse = 1 = text = In the beginning God created the heaven and the earth(但用西类牙语)En el principio, Dios creó los cielos y la tierra。

MYSQL结构在latin1_swedish_ci,用latin1_spanish_ci测试,同样问题,用UTF8测试,差

最佳答案

您需要修改提交 L 的脚本并对其进行 URL 编码,同时接收脚本 URL 对其进行解码。

关于php - 在 MYSQL 中搜索具有西类牙口音的圣经网站字符集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30352967/

相关文章:

php - mysql 查询到 laravel 查询

c# - 在 C# 上使用参数从一个数据库复制另一个数据库中的行

php - 您可以在PHP的Elasticsearch上使用命名查询吗?

php - 文本的索引词

HTML 5 - anchor 不适用于 ios Safari

mysql - 在同一个表中左连接mysql查询

php - 用 php 返回特定的 http 状态码

php - MYSQL - 文件名的字段类型?

html - CSS3 自定义工具提示淡入淡出

javascript - 如何使用jquery自动生成动态表的总价?