如何将数据从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.
我想获得存储在Mysql中的表单标签,这样我就可以使用select语句轻松显示任何语言。 >
这就是我所做的,但由于我有不同的语言,因此很难实现。
任何指导都将受到赞赏。 p>
p>
div>
答
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>