Hi,
i'm working on a website where i select some text from DB according to the language selected:
Here's where i define the language (where default = 'pt'):
<?php
//array
$lang = array('pt', 'en');
//iniciar sessao -> array
session_start();
//verificar var lang no url -> pagina.php?lang=pt
if(isset($_GET['lang']) && in_array($_GET['lang'], $lang))
{
$_SESSION['lang'] = $_GET['lang'];
}
else
{
$_SESSION['lang'] = 'pt';
}
//incluir a linguagem
if(isset($_SESSION['lang']) && in_array($_SESSION['lang'], $lang))
{
require_once 'lang_'.$_SESSION['lang'].'.php';
}
?>
And here is where i'm selecting the text:
<?php
ob_start();
include 'common.php';
include 'db_connect.php';
if (isset($_GET['lang']))
{
$sel_lang="SELECT * FROM content_lang WHERE lang='".$_GET['lang']."'";
$language=mysql_query($sel_lang, $connect);
$row_lang=mysql_fetch_assoc($language);
$sel_text="SELECT * FROM content_lang WHERE titulo='Family Office' AND lang='".$row_lang['lang']."'";
$text=mysql_query($sel_text, $connect);
$row_text=mysql_fetch_assoc($text);
?>
<span class="fontchange"> <?php echo $row_text['titulo'];?> </span>
<?php echo $row_text['descricao']; ?>
<?php
$content=ob_get_contents();
ob_clean();
$title="Familly Office";
$image="familyoffice2.png";
include 'include/master.php';
}
?>
I want to say that if lang = default the text is portuguese (pt).
Can someone help me?
Thank you,
PF2G