gpt4 book ai didi

php - 如何从 MySQL 数据库中获取 “Hindi” हिन्दी 文本(印度本地语言)

转载 作者:行者123 更新时间:2023-11-29 04:06:17 24 4
gpt4 key购买 nike

存储我的数据的数据库是这样的:

enter image description here

现在我想获取该数据并显示在我的 php 页面上,但是当我尝试在我的 php 代码中获取数据时,我正在将文本输入以下格式

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

关于这个问题,我已将我的数据库字符集更改为“utf8_unicode_ci”,但仍然无法正常工作。我写了下面的代码来获取数据

数据库连接页面

<?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);
}
?>

和索引页

<?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";
?>

最佳答案

你需要使用“set_charset”

试试这个:(在你的 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");

准确地说,在您的情况下,您需要在获取数据库的代码中添加:

mysqli_set_charset( $db, 'utf8');

关于php - 如何从 MySQL 数据库中获取 “Hindi” हिन्दी 文本(印度本地语言),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37716229/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com