PHP - 显示从MySQL DB检索的Urdu文本

时间:2022-09-18 22:05:33

There are book titles in Urdu language stored in MySQL database. I've to display on html page using PHP.

在MySQL数据库中存储了Urdu语言的书名。我将使用PHP在html页面上显示。

Currently only questions marks(??????) are displayed in place of Urdu text.

目前只显示问号(??????)代替乌尔都语文本。

<div class='product_title'><a href='details.php?pid=".$Row['s_id']."'>".$Row["books"]."</a></div>

What needs to be done to display these characters properly?

要正确显示这些字符需要做什么?

2 个解决方案

#1


17  

Step : 1 - Go to table structure and change collation latin1_swedish_ci to utf8_general_ci

步骤:1 - 转到表结构并将排序规则latin1_swedish_ci更改为utf8_general_ci

Step : 2 - You have to include this following tag in data results pages.

步骤2 - 您必须在数据结果页面中包含以下标记。

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Step :3 - Insert 'N' Prefix. Here the N stands for National language character set. Which means that you are passing an NCHAR, NVARCHAR or NTEXT value, more

步骤:3 - 插入'N'前缀。这里N代表国家语言字符集。这意味着您传递的是NCHAR,NVARCHAR或NTEXT值,等等

Step :4 - PHP code displaying records form database. Before that you have to specify mysql_query() function data character set type

步骤:4 - PHP代码显示记录表单数据库。在此之前,您必须指定mysql_query()函数数据字符集类型

<?php
include('db.php');
mysql_query ("set character_set_results='utf8'"); 
$query = mysql_query("SELECT * FROM books") or die(mysql_error());
while($row=mysql_fetch_array($query))
{
echo $row['id']; // Book id 
echo $row['books_title']; // Book title
}
?>

#2


1  

Also your files encoding mustbe utf-8 without BOM

您的文件编码也必须是utf-8而没有BOM

#1


17  

Step : 1 - Go to table structure and change collation latin1_swedish_ci to utf8_general_ci

步骤:1 - 转到表结构并将排序规则latin1_swedish_ci更改为utf8_general_ci

Step : 2 - You have to include this following tag in data results pages.

步骤2 - 您必须在数据结果页面中包含以下标记。

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Step :3 - Insert 'N' Prefix. Here the N stands for National language character set. Which means that you are passing an NCHAR, NVARCHAR or NTEXT value, more

步骤:3 - 插入'N'前缀。这里N代表国家语言字符集。这意味着您传递的是NCHAR,NVARCHAR或NTEXT值,等等

Step :4 - PHP code displaying records form database. Before that you have to specify mysql_query() function data character set type

步骤:4 - PHP代码显示记录表单数据库。在此之前,您必须指定mysql_query()函数数据字符集类型

<?php
include('db.php');
mysql_query ("set character_set_results='utf8'"); 
$query = mysql_query("SELECT * FROM books") or die(mysql_error());
while($row=mysql_fetch_array($query))
{
echo $row['id']; // Book id 
echo $row['books_title']; // Book title
}
?>

#2


1  

Also your files encoding mustbe utf-8 without BOM

您的文件编码也必须是utf-8而没有BOM