How to make a website in multiple languages using PHP MySQL

How to make a website in multiple languages using PHP MySQL

, Writer

In this tutorial am going to describe the most popular techniques of creating database Table for multi-language text support.

Follow these steps to create a dynamic multi-language website in PHP and MySQL.

Step 1. Create simple table name test in MySQL database using PHPMyAdmin GUI tool. create table Step 2. Create/Manage Table column like “Name, Type, Lenght, Default, Collation, AI and most important to set column attribute collation = utf8_general_ci.

utf8-general_ci

Step 3. Run Mysql Query to insert one record in test table.

INSERT INTO `test` (`t_id`, `t_uid`, `t_text`, `t_date`) VALUES (NULL, '23', 'हो। गए, उनका एक समय में बड़ा नाम था। पूरे देश में तालाब बनते थे बनाने वाले भी पूरे देश में थे। कहीं यह विद्या जाति के विद्यालय | सिखाई जाती थी तो कहीं यह जात से हट कर एक विशेष पांत भी जाती थी। ', '12-11-2018');

hindi data

Step 3. Create a php Page with full html & you must add two meta gat.

<meta http-equiv="Content-Language" content="en,hu">
<meta charset="UTF-8">

Step 4. Here is php code for connect page to mysql database.

<?php
$con = mysql1i_connect("localhost","user","******","database");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?>

<!DOCTYPE html> 
<html>
 <head> 
<title>website in multiple languages</title>
 <meta http-equiv="Content-Language" content="en,hu">
 <meta charset="UTF-8">
 </head>
 <body>
<p>
<?php
// Retrieve text for all languages
$sql = "SELECT * FROM `t_text`;
if($result = mysql_query($con,, $sql)){
    while($row = mysql_fetch_array($result)){
        echo "Language (".$row["id_id"]."): ".$row["t_text"]."<br>";
    }
}
?>
</p>
 </body>
 </html>

Comments / Answer

Leave a comment & ask question