?
Solved

Multi language problems with DB

Posted on 2002-05-01
3
Medium Priority
?
291 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 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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.
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

800 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