douyu4535 2013-08-30 08:59
浏览 33

PHP MySQL多语言网站

I am trying to build an English and French website by pulling the information from a MySQL table but I am stuck. I think that kind of query is too advance for me. My idea is having a table with both language translated and assign them with an ID.

Here's the table lang

+--------+-------------------+----------------------+
| id     | English           | French               |
+--------+-------------------+----------------------+
| 1      | Verbal Warning    | Avis verbal          |
| 2      | Written Warning   | Avis écrit           |
| 3      | Evaluation        | Évaluation           |
| 4      | Other (specify)   | Autres (spécifiez)   |
+--------+-------------------+----------------------+

Then I have another table that people inputs 'Topic' into the database. So when I switch the page to French the content of the table will display in French.

+-----------+---------+
| EMP_ID    | Topic   |
+-----------+---------+
| 845689    |  4      |
| 185648    |  3      |
| 485497    |  1      |
| 416798    |  2      |
+-----------+---------+

I want the ouput to be this in a table when we're on the English page

+-----------+------------------+
| EMP_ID    | Topic            |
+-----------+------------------+
| 845689    |  Other (specify) |
| 185648    |  Evaluation      |
| 485497    |  Verbal Warning  |
| 416798    |  Written Warning |
+-----------+------------------+

then this when it's the French page is selected.

+-----------+---------------------+
| EMP_ID    | Topic               |
+-----------+---------------------+
| 845689    |  Autres (spécifiez) |
| 185648    |  Évaluation         |
| 485497    |  Avis verbal        |
| 416798    |  Avis écrit         |
+-----------+---------------------+

Is there a way to make it work or there's easier ways to display

  • 写回答

5条回答 默认 最新

  • dongqiongjiong4740 2013-08-30 09:03
    关注

    There is no reason to keep lang schema in DB, try to include files with your lang instead.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据