Friday, December 31, 2021

[FIXED] I want to use urdu in webpage using codeigniter framework?

Issue

I am developing a website using urdu in codeigniter framework. I want to load urdu in my webpages but I failed every time. I send urdu to database in uni code when I am trying to access urdu data and show it in webpage it show me some other things which is in attachment. This is screenshot of webpage

I already used meta tag below

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

How can I write urdu in webpage using codeigniter framework.


Solution

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

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


Answered By - Rana Ghosh

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.