dpdbu24262 2016-06-09 03:21
浏览 156
已采纳

如何从MySQL数据库中取“印地语”हिन्दीtext(印度当地语言)

Database which stores my data is this:

enter image description here

Now I want to fetch that data and display on my php page, but when I'm trying to fetch data in my php code I'm getting text into the following formate

UID= ????/??????????/????/?????/?????/Test upgrade/1
UID= ????/??????????/??????/??????/??????????/159/1
UID= ????/??????????/??????/??????/??????????/190/1
UID= ????/??????????/??????/??????/??????????/194/1
UID= ????/??????????/??????/???????/?????? (??.)/730/1
UID= ????/??????????/??????/???????/?????? (??.)/742/1/1
UID= ????/??????????/??????/???????/?????? (??.)/732/1
UID= ????/??????????/??????/??????/??????/98/8/1
UID= ????/??????????/??????/??????/??????/48/10/1

Referring to this question I have changed my database charset to "utf8_unicode_ci", but Still not working. I have written following code to fetch the data

datebase connection page

<?php
    // Database configuration
    $dbHost = "localhost";
    $dbUsername = "user";
    $dbPassword = "xxxxxxxxxxxxx";
    $dbName = "tutorialsssxxxxx";

    // Create database connection
    $db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);

    // Check connection
    if ($db->connect_error) {
        die("Connection failed: " . $db->connect_error);
    }
?>

and index page

<?php
include $_SERVER['DOCUMENT_ROOT']."/header.php";
?><br>

<!DOCTYPE HTML>
<html lang="hi">
<head>
<title><?php echo $_GET['dta']; ?> Tutorials  Mrtutorials.net</title>
<link href='style.css' rel='stylesheet' type='text/css'>
<script src="jquery.min.js"></script>
<script type="text/javascript">
// Show loading overlay when ajax request starts
$( document ).ajaxStart(function() {
    $('.loading-overlay').show();
});
// Hide loading overlay when ajax request completes
$( document ).ajaxStop(function() {
    $('.loading-overlay').hide();
});
</script>


</head>
<body>      
<div class="content">
    <div class="dta"> <div class="list_item"><h2><?php echo $_GET['dta']; ?> Tutorials</h2></div>
<div class="post-wrapper">
    <div class="loading-overlay"><div class="overlay-content">Loading.....</div></div>
    <div id="posts_content">
    <?php
    //Include pagination class file
    include('Pagination.php');

    //Include database configuration file
    include('dbConfig.php');

    $limit = 10;

    //get number of rows
    $queryNum = $db->query("SELECT COUNT(*) as postNum FROM posts");
    $resultNum = $queryNum->fetch_assoc();
    $rowCount = $resultNum['postNum'];

    //initialize pagination class
    $pagConfig = array('baseURL'=>'getData.php', 'totalRows'=>$rowCount, 'perPage'=>$limit, 'contentDiv'=>'posts_content');
    $pagination =  new Pagination($pagConfig);

    //get rows
    $query = $db->query("SELECT * FROM posts Where type=$yyy ORDER BY id DESC LIMIT $limit");

    if($query->num_rows > 0){ ?>
        <div class="posts_list">
        <?php
            while($row = $query->fetch_assoc()){ 
                $postID = $row['id'];
        ?>

<table width="" border="0" cellspacing="5" cellpadding="0">
   <tr class="up"> 
     <td style="font-size: 45px; padding-left:5px; padding-right:5px"><?php echo $row["id"]; ?></td>
     <td valign="left" width="100%"><a href="/Ask/<?php echo $row["id"]; ?>/<?php echo $row["folder"]; ?>"><?php echo $row["title"]; ?></a> <br>  <?=$value['type']?></td>
   </tr>
 </table>

        <?php } ?>
        </div>
        <?php echo $pagination->createLinks(); ?>
    <?php } ?>
    </div>
</div></div>
</div>

</body>
</html><?php
include $_SERVER['DOCUMENT_ROOT']."/footer.php";
?>
  • 写回答

4条回答 默认 最新

  • duanluan8390 2016-06-09 03:43
    关注

    You need to use "set_charset"

    Try this: (in your index.php)

    //initialize pagination class
        $pagConfig = array('baseURL'=>'getData.php', 'totalRows'=>$rowCount, 'perPage'=>$limit, 'contentDiv'=>'posts_content');
        $pagination =  new Pagination($pagConfig);
    
        mysqli_set_charset( $db, 'utf8');
    
        //get rows
        $query = $db->query("SELECT * FROM posts Where type=$yyy ORDER BY id DESC LIMIT $limit");
    

    To be precise, In your case you need to add this in code where you fetching the db:

    mysqli_set_charset( $db, 'utf8');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)