简体   繁体   中英

How to display data from database in html via php in other language?

I have a problem with PHP. In database, the whole information is written in Armenian, and I want to get that data and display it on the screen using PHP and HTML. But when I write,

$conn = new mysqli("some-host", "some-username", "some-password", "some-website");
$sql = "SELECT * FROM categories";
$result = $conn->query($sql);

while($row = $result->fetch_assoc()) {
    echo "id: " . $row["id"]. " - Category: " . $row["category"]."<br>";
}

the output is:

id: 1 - Category: ????????? ?????????????
id: 2 - Category: ??????????? ?????????????
id: 3 - Category: ???

What I must to do to change "?" symbols into Armenian letters?

mysql set charset


SET NAMES 'utf8'
SET CHARACTER SET utf8

Or

ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM