-3

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

3
  • Can you rephrase your question to be more specific? If you actually, in fact, did what your screenshot shows, you should know more than enough to achieve what I think you are asking.
    – pinate
    Sep 14, 2013 at 0:37
  • @nate i don't know how to get the form label names from the database what i have shown is only static way
    – Suma
    Sep 14, 2013 at 0:52
  • Have you considered using the us2.php.net/manual/en/function.gettext.php function? That's probably a better choice.
    – pinate
    Sep 14, 2013 at 1:00

1 Answer 1

1

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>

Not the answer you're looking for? Browse other questions tagged or ask your own question.