Hello all,
I am trying to use "charset=utf-8" in my program, for handling 'hindi' language (indian).
The task is to accept inputs from users in 'hindi' language, store in DB and display in the same language as per search.
Is there any method to relate the english key-strokes with 'Hindi'?
e.g. how to type the equivalent word for [ 'universe' in english ] in 'Hindi'.
What precautions are to be taken through program, if the visitor browser does not support 'unicode' display format?
Following is the code to accept value from user.
******* unicode_sample.php
<?php include "connection.php"; // to connect with the database ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form name="my_form" method="post" action="act_unicode_sample.php">
<table> <tr>
<td height="27" align="left"> </span>Program Venue </td>
<td align="left">
<input type="text" size="50" maxlength="100" name="prg_venue_v" style="font-family: Mangal" value="">
<!-- Mangal is the font for hindi language -->
</td>
</tr> </table>
<table> <tr>
<td colspan="4" height="26" align="center" class="engfont">
<input type="submit" value="Submit"> </div>
</td> </tr> </table>
</form>
</body>
Following is the program to store the value in DB
********* act_unicode_sample.php
<?php include "connection.php"; //to connect with the database ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
$prg_venue_v = $_POST['prg_venue_v'] ;
?>
<?php
$q="INSERT INTO programs (program_venue) VALUES('$prg_venue_v')";
echo " query formed $q <br> " ; // the check proper query formed or not
$query="SET NAMES 'utf8' "; // this was suggested by one of friend, did't understand the purpose
$query="SET CHARACTER_SET utf8;"; // this was suggested by one of friend, did't understand the purpose
$result = mysql_query($q) or die("insert failed");
echo " query executed" ; // message to check whether execution has reached the last part of program
?>
</body>
Follwoing is the program to display the values from DB
******** unicode_display.php
<?php include "connection.php"; ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
$qry = "SELECT program_venue FROM programs";
echo " query formed $qry <br> " ; // to check proper query is formed or not
$res = mysql_query($qry);
// while loop is to read the values from DB and display
while ($row = mysql_fetch_array($res))
{
echo "$row[program_venue]";
echo "<BR>" ;
}
?>
</body>
The rows are fetched from DB, but the characters are not properly readable.
Please help me in this regard.
I have attached the sample file of data stored in table.
Thanks in advance.
Looking for help.