如何在php中显示mySQL表中的Unicode文本?

时间:2017-06-22 05:06:14

标签: php mysql unicode

我想在mySql数据库中显示我的网站中的unicode文本,我在unicode整理中创建了表格,但是我无法通过unicode文本显示文本,请参考我创建的代码。

<!Doctype html>
<html>
<head>
<title>Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
*{
    font-family:Latha;
}
</style>
</head>
<body>
<?php 
    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbName = "mydb";

    //Create connection
    header("content-type: text/html; charset=UTF-8");  
    $conn = new mysqli($servername, $username, $password, $dbName);

    //Check connection
    if($conn->connect_error){
        die("Connection Failed : ". $conn->connect_error);


    }



    $sql="select txt, txt1,txt2 from dav";
    //mysqli_set_charset($sql, 'utf8');
    $result=$conn->query($sql);

    if($result->num_rows>0){
        //output data
        while ($row=$result->fetch_assoc()){
            echo "<div><p>" .$row["txt"]. "</p><p>" .$row["txt1"]. "</p><p>" . $row["txt2"]. "</p></div>";
        }

    }
    else{
        echo "No data found";
    }
    $conn->close();
?>

</body>
</html>

和输出就像这样

?????????? ????? ?????? ???????? ???????????? ????????? ??????。

?????????? ????? ?????? ???????? ???????????? ????????? ??????。

?????????? ????? ?????? ???????? ???????????? ????????? ??????。

但我想这样

வான்நினநினறுறுஉலகமவழஙவழஙவழஙவழஙவருதலாலதானதானதானதானதானதானதானதானதானதானதானதானதானதானதானபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாற வான்நின்றுறு்வழஙவழஙகிகிவருதலாலதானதானதானதானதானதானதானதானதானதானதானதானபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாறபாற வானவானநினநினறுறுவழஙவழஙவழஙவழஙதானதானதானதானதானதானதானதானதானதானதானதானறுறுறுறுறுறுறுறுறுறுறு<று<றுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறுறு

请帮我解决这个问题。

0 个答案:

没有答案