PHP tutorials,a way to getting some thing new in web

Followers

Powered by Blogger.

Friday 1 August 2014

How To get Any Language stored in Database with that language

No comments :

This is quite trick that we can store any language in database but on retrive without html it is difficult.specially when we work in android and iphone services.






here is code for that.you will get surprise that you donot need to use json_encode().see following code:

<?php
header('Content-Type: text/html; charset=utf-8');
include("config.php");
mysql_query("SET character_set_results=utf8");
mb_language('uni');
mb_internal_encoding('UTF-8');
mysql_query("SET NAMES 'utf8'");
$select="SELECT * FROM enghindi order by id LIMIT 500";
$result=mysql_query($select) or die(mysql_error());
$content= '{"Status":"Success","Data": [';
while($row=mysql_fetch_array($result))
{
$id=$row['id'];
$hindi_data=$row['hindi_data'];
$english_data=$row['english_data'];
$content1.= '{
"id":"'.$id.'",
"hindi_data":"'.$hindi_data.'",
"english_data":"'.$english_data.'"
},';
}
$content1=rtrim($content1,',');
$content.=$content1. ']}';

echo $content;
?> 


Following would be table fields:




No comments :

Post a Comment