Recently I’m working on bangla. The part of this work I learn how to insert & retrieve bangla into MYSQL database using PHP.
Now I’ll discuss the whole process of insert & retrieve bangla into MYSQL database.
It is very easy, we all know how insert & retrieve data from database. Bangla font inserting is almost same. Only two queries are extra needed.
First we have created a database & table using MYSQL to insert bangla.
Now open the mysql command prompt & create database named bangla, & create a table named data.
Now write those command:
- mysql> set names ‘utf8′;
- mysql> create database bangla character set utf8 collate utf8_general_ci;
- mysql> use bangla;
- mysql> create table data (name varchar(100) character set utf8 collate utf8_general_ci);

Insert Bngla into database:
So we create database & table for where we insert bangla font. Now we have to create a simple form where we input bangla word.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
</head>
<form method=”get” action=”bangla.php”>
insert bangla<input name=”name” type=”text” />
<br />
<br />
<input type=”submit” value=”insert bangla” />
</form>
<body>
</body>
</html>
Now just copy the code & save as banglainput.php.

Now insert bangla font into database.
<?php
$cnt = mysql_connect(“localhost”,”root”) or die (“could not localhost”);
mysql_select_db(‘bangla’,$cnt);
//********This Two Lines for bangla*********//
mysql_query(‘SET CHARACTER SET utf8′);mysql_query(“SET SESSION collation_connection =’utf8_general_ci’”) or die (mysql_error());
//*******************************************//
$sql = mysql_query(“insert into data values(‘$_GET[name]‘)”) or die(“error to creating row”);
$results = mysql_query(“select *from data”,$cnt);
echo “the results is “;
while($row = mysql_fetch_array($results))
{
echo $row['name'] .’ ‘;
}
?>

Now copy these code and save as bangle.php.
You must add these two lines just after selecting the database, i.e mysql_select_db() function.
mysql_query(’SET CHARACTER SET utf8′);
mysql_query(”SET SESSION collation_connection =’utf8_general_ci’”);
Its very easy Just Copy those code paste and run. Ooo the most importnt thing, you need a unicode for insert & retrive. i use avro unicode. So you must download avro unicode.
this tutorial is referenced by saidur vai.
Recent Comments