Code: Select all
<select id="tdd" name="tdd" >
<option value="À" >À</option>
<option value="Á" >Á</option>
<option value="Ã" >Ã</option>
<option value="Â" >Â</option>
</select>
Code: Select all
<?php
$term = mysqli_real_escape_string($conn, $_POST['tdd']);
//
$sql = "SELECT COUNT(`id`) FROM `test_table` WHERE `character_field` = '" . $term . "' ";
$qry = mysqli_query($conn, $sql);
$ary = mysqli_fetch_array($qry);
$row = $ary[0];
//
echo $row;
echo '<br />';
echo $sql;
?>
--
8
SELECT COUNT(`id`) FROM `test_table` WHERE `character_field` = 'Á'
--
8 being the number of records in my table and the query below it with the specific character selected.
How do i deal with these type of characters when searching for them in the database?
The collation for the field in question (character_field) is latin1_swedish_ci. Do i have to change this when dealing with non-english characters? The charset for the page is iso-8859-1.
Thanks in advance
Edit
Setting the collation for the specific field to latin1_general_ci returns 2 rows per search; it seems the problem is that the à and ã is seen as the same character for some reason.
Edit
Looks like i found a solution : latin1_general_cs as collation solves the problem.