I have a checkbox, which changes the content of a table when it's clicked.
For some reason, my UTF-8 is no longer working after I have submitted the form with ajax.
Ajax:
function showUser() {
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("table").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?customer="+variable);
xmlhttp.send();
}
and getuser.php:
$customer = intval($_GET['customer']);
$connection = mysqli_connect('localhost','root','*********','name');
if (!$connection) {
die("Could not connect: " . mysqli_error($connection));
}
if($customer == 1) {
$searchType= 1;
} else {
$searchType= 0;
}
$sql="SELECT * FROM table WHERE type= $searchType";
$result = mysqli_query($connection,$sql);
After this I echo a table with content got from the database. In my database there is some customers that has some special characters in their name. Instead of showing them like usual, it only shows ? in place of those special characters.
Any help? (sry for my bad english)