dtny30176 2013-09-14 00:32
浏览 25
已采纳

如何将数据从mysql数据库显示到php中的标签? [关闭]

I want to get form labels that are stored in Mysql so i can easily display any language using select statement.
this is what i did but its hard to implement since i have different languages.
any guidance will be appreciated.

form

  • 写回答

1条回答 默认 最新

  • dtpfia3334 2013-09-14 02:51
    关注

    It's better to store labels in php document, than in your html document call it with echo based upon language selection.

    PHP - filename e.g. lang-en.php

    <?php
    
      // Language English
    
      $name   = 'Name';
      $phone  = 'Phone';
      $street = 'Street';
    
    
      // and so on...
    ?>
    

    HTML - must be with .php extension! e.g. index.php

    <!doctype html>
    
    <html>
    
    <head>
    
    </head>
    
    <body>
    include('lang-en.php'); <!-- Include default language -->
    
      <!-- Process select with jQuery/AJAX to include file in your index.php based upon selection -->
    
      <form id="select-lang">
        <select id="language">
          <option value="en">English</option>
          <option value="de">Deutsch</option>
          <option value="es">Espanol</option>
        </select>
      </form>
    
      <form>
        <label for="name"><?php echo $name; ?></label>
        <input name="name" type="text" id="name"/>
      </form>
    
    </body>
    
    </html>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿