I am trying to make a website in different languages and I retrieve this information from a database. For now I have two languages in there: English and Dutch.
What I would like to do is getting all the language possibilities and put this into a switch. So if people will click on for example this link: index.php?page=NL they will get the Dutch translation of the page.
So this is the code that I am using. It works so far but it shows I think the language option and the default option. Because when I remove default I only get the code ones.
<div id="content">
<?php
//Retrieve languages
$querySwitchLang = "SELECT * FROM languages";
$resultSwitchLang = mysql_query($querySwitchLang);
?>
<?php
while($rowSwitchLang = mysql_fetch_array($resultSwitchLang)){
switch($page){
case $rowSwitchLang['langCode']:include('page.php');break;
default: include('pageDefault.php');
break;
}
}
?>
</div>
So actually I wanted to have it like this because now it runs the switch statements as many times as there are languages I think:
<div id="content">
<?php
//Retrieve languages
$querySwitchLang = "SELECT * FROM languages";
$resultSwitchLang = mysql_query($querySwitchLang);
?>
<?php
include('functions.php');
switch($page){
while($rowSwitchLang = mysql_fetch_array($resultSwitchLang)){
case $rowSwitchLang['langCode']:include('page.php');break;
}
default: include('pageDefault.php');
break;
}
?>
</div>
But this doesn't work because then I will get this error:
Parse error: syntax error, unexpected 'while' (T_WHILE), expecting case (T_CASE) or default (T_DEFAULT) or '}' in C:\wamp\www\glimpler\index.php on line 6
I can't realy figure out how to solve this problem.