For the code below how do I output the MySQL query with UTF-8 support ?
<?php
$servername = "###";
$username = "###";
$password = "###";
$dbname = "###";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT Column1, Column2, Column3 FROM table ORDER BY Column1 DESC";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
echo '<table class="">';
echo "<tr><th>Column1</th><th>Column2</th></tr>";
while($row = mysqli_fetch_assoc($result)) {
echo "<tr><td>";
echo '<a href="' . $row['Column1'] . '" target="_blank">' . $row['Column3'] . '</a>';
echo "</td><td>";
echo $row['Column2'];
echo "</td>";
}
} else {
echo "Error.";
}
echo "</table>";
mysqli_close($conn);
?>
What are the options for a clean output of UTF-8 characters? I tried several solutions found here and on other forums but I gave up. The database Collation is utf8_unicode_ci