Hi, I need some help with my alphabet index search...
The index search works well and does what it's supposed to, except for when it comes to special native characters. Then is either displays a wrong result or no result at all (with no errors).
Everything is set to the charset UTF8:
My database, the database table and the search page containing the
PHP code.
When a special native character is selected in the alphabet search, the search returns consistent results. But not correct results.
A demo would help describe the issue better:
There is only ONE entry in my table that starts with the letter Á (A with a coma on top).
When the following letters are selected in the alphabet search [ A, Á, Ð, Í and Ý] they give results for that ONE entry that starts with the Á. character). NOT JUST THE SEARCH FOR "Á"
How can I fix this?
Here is that pages relevant code:
- PHP: Select all
<?
session_start();
include("database.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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Alpabet search</title>
</head>
<body>
<!-- When the following link is pressed, the PHP shows reults -->
<a href="search.php?var=Á" target="_self">Á</a>
<?php
if ( isset( $_GET['var'] ) )
{
$query = "SELECT * FROM table WHERE column LIKE '". $_GET['var'] ."%' ORDER BY column ASC";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
// If no results:
if ($numrows == 0)
{
echo "No results that start with ";
echo "". $_GET['var'] ."";
}
// Get results
$q .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
// While results, print:
while ($row= mysql_fetch_array($result))
{
$name = $row["Name"];
echo "Results for letter: ";
echo "". $_GET['var'] ."<br /><br />";
echo "$name<br />";
$count++ ;
} // End while loop
} // End IF
?>
</body>
</html>
I've tried adding COLLATE UTF8_icelandic_ci to the query.
I've also tried adding mysql_real_escape_string() to the $name string in the while loop. But I've had no luck.
Any help would be great as this is the only thing left before publishing my new site.