我想获得存储在Mysql中的表单标签,这样我就可以使用select语句轻松显示任何语言 这就是我所做的,但由于我有不同的语言,因此很难实现。 任何指导将不胜感激。
答案 0 :(得分:1)
最好将标签存储在php文档中,而不是在html文档中使用基于语言选择的echo调用它。
PHP - 文件名,例如琅en.php
<?php
// Language English
$name = 'Name';
$phone = 'Phone';
$street = 'Street';
// and so on...
?>
HTML - 必须使用.php扩展名!例如的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>