PHP - 显示从MySQL DB检索的Urdu文本 [英] PHP - Displaying Urdu text retrieved from MySQL DB

查看:118
本文介绍了PHP - 显示从MySQL DB检索的Urdu文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



目前只显示问题标记( )以代替乌尔都语文本。

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

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

解决方案

步骤1:转到表格结构并将整理格式 latin1_swedish_ci 更改为 utf8_general_ci b

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

 < meta http-equiv =Content-Typecontent =text / html; charset = UTF-8/> 

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



步骤:4 - 显示数据库记录的PHP代码。之前你必须指定mysql_query()函数数据字符集类型

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


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

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?

解决方案

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

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

<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

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

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

这篇关于PHP - 显示从MySQL DB检索的Urdu文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆