I will run a bible website so I created the database with MYSQL default charset latin1_swedish_ci but the site will be in spanish.
The problem is that the book of Génesis uses accents and so does Éxodo and Josué so when people search for example:
$getbook = $_GET['L'];
$bible = mysqli_query($database, "SELECT * FROM `bible` WHERE `book` LIKE '%$getbook%'");
If people searches for Genesis without accents there are results but if people search for Génesis WITH accent then there are no results.
Here is the script I show results:
<?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> </td>
<td> </td>
<td> </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
}
?>
The results text are ok the only problem is when you search using accents. It show results for Genesis but not for Génesis with accent.
Here is the real site to test:
WITH ACCENT:
http://santabiblia.cl/?L=Génesis
no results
WITHOUT ACCENT:
http://santabiblia.cl/?L=Genesis
Yes we have results
Any idea?
EDIT
The database looks like
DB_NAME bible -> book - chapter - verse - text
example
book = Génesis (with accent) chapter = 1 verse = 1 = text = In the beginning God created the heaven and the earth (but in spanish) En el principio, Dios creó los cielos y la tierra.
The MYSQL structure is in latin1_swedish_ci, tested with latin1_spanish_ci and the same problem, tested with UTF8 and it is worse
您将需要修改提交L
的脚本并对其进行URL编码,而接收脚本URL对其进行解码。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.