Solved

Multi language problems with DB

Posted on 2002-05-01
3
290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

688 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