Solved

Multi language problems with DB

Posted on 2002-05-01
3
281 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now