Web development basic and advance tutorial, php basic tutorial, laravel basic tutorial, React Native tutorial

Friday, October 23, 2015

Bangla insert and retrive using php & mysql

0 comments

Bangla insert and retrieve using php & mysql

in this tutorial I will explain how to "Bangla insert and retrieve using php & mysql ". mysql is a relational database. you can use for large scale business database.

Lets see how to insert and retrieve bangla font into the Mysql Database using PHP. We see the step for that.

·  First we Create a MySql database and tables which supports Bangla.
·  Insert Bangla value in the database .
·  Retrieve Bangla from the database.




Create Database to support Bangla :

We give the database name bangla and it has 1 table which name is profile .We do that by phpMyadmin :
  • To create the database set character utf8_general_ci.

To keep things simple and easy to understand open the mysql command
prompt.
  • mysql> set names ‘utf8′;
  • mysql> create database bangla character set utf8 collate utf8_general_ci;
  • mysql> use bangla;
  • mysql> create table profile (profile_name varchar(100) character set utf8 collate utf8_general_ci);

Insert Bangla :

So we create a database. Now we insert the value into the database. Insert Bangla Value in the database :
We create a simple form :
Input Form

Then we will insert into the database :

We create a connection .

1. $c = mysql_connect(“localhost”,”root”,””);
2. mysql_select_db(‘bangla’) or die (mysql_error());
//******These two line are used for Bangla Character *********/
3. mysql_query(‘SET CHARACTER SET utf8′);
4. mysql_query(“SET SESSION collation_connection =’utf8_general_ci’”) or die (mysql_error());
//***************************************************/
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’”);


Now we will insert :

if(isset($_POST))
{
mysql_query(“insert into profile values($_POST[“username])) or die (mysql_error());
echo ‘saved into database’;
}
else
{
echo ‘Not posted’;
}
Now we check how the font stores into the database .

No comments:

Post a Comment