Solved

Multi language problems with DB

Posted on 2002-05-01
3
284 Views
Last Modified: 2006-11-17
Hello

To show my query data in a table i use the following code:

$myarray=array("NAME","STREET","POSTAL") and so on...

$result=("select * from my table");
while($row=mysql_fetch_array($result)) {
  reset($myarray);
  echo "<table>";
  while (current($myarray)) {
     echo "<tr><td>".current($myarray)."</td>";
     echo "<td>".$row[current($myarray)]."</td></tr>";
  }
  echo"</table>";
}

Now i want to make my page multi language and i want the description of each field in the selected language.

I try to do something like that:

the vars l_name ... comes from the selected language file

$myarray=array("NAME" => $l_name, "STREET" => $l_street, "POSTAL" => $l_postal);

$result=("select * from my table");
while($row=mysql_fetch_array($result)) {
  reset($myarray);
  echo "<table>";
  while (list($key,$value)=each(current($myarray)) {
     echo "<tr><td>".current($key)."</td>";
     echo "<td>".$row[current($value)]."</td></tr>";
  }
  echo"</table>";
}
 
This does not work.
Any idee how to do this???

Thanks,
seever

0
Comment
Question by:Seever
3 Comments
 
LVL 8

Expert Comment

by:us111
ID: 6985545
what's your fields name in different language ??
NAME_FR......
0
 
LVL 1

Accepted Solution

by:
teuy earned 50 total points
ID: 6985560
// Key of $myarray is a name of table field and value of $myarray is a display message, right?
$myarray=array("NAME" => $l_name, "STREET" => $l_street, "POSTAL" => $l_postal);

$result=("select * from my table");
while($row=mysql_fetch_array($result)) {

     print "<table>";
          foreach( $myarray as $FieldName => $DisplayFieldName )
               print "<tr><td>$DisplayFieldName</td><td>".
             $row[$FieldName]."</td></tr>";
     print "</table>";
} //EndWhile Getting eachrow

0
 
LVL 1

Author Comment

by:Seever
ID: 6985586
l_name, l_street ...
I use different laguage files but the variables are the same.

I call my language files with

$lang = "language/language_".$language.".inc";
require($lang);

my fieldnames in my DB are caling NAME, STREET, ....
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question