2011-03-19 21 views
0

我是網絡開發新手,我希望我的網站有一個下拉菜單,將改變我的網站的語言。我想要一個解決方案,不會要求我創建新網站的全新html。我還想要一種方法來創建一個輸入字段,它會要求用戶添加一個數字,然後它會在數字後面自動添加一個單詞。如何製作一個菜單,將改變我的網站的語言

回答

0

不知道句子的第二部分是什麼,但做這件事的一個簡單方法是服務器端腳本。例如,如果您使用的是PHP,我建議您回顯一個變量,而不是實際在其所屬的位置輸入內容。相反,將內容存儲在數據庫中,然後根據選擇的語言(存儲此會話變量)將其存儲在數據庫中,然後將其存儲在變量中,並在變量被回顯時使用bam。

0

在PHP中使用$ _GET創建[l];

<?php 
    if($_GET[l]=='en') 
    { 
      echo 'Welcome'; 
    } 
    else if($_GET[l]=='sk') 
    { 
      echo 'Vítajte'; 
    } 
    else if($_GET[l]=='de') 
    { 
      echo 'Wilkommen'; 
    } 
    else 
    { 
      echo ''; //Here set your default language. For example if is not set- automatically to english 
    } 
?> 

菜單:

<?php 
    if(isset($_GET[topic])) 
     { 
       //This is code, if you use another $_GET[...] 
       //Without this, page will crash ,while it shows another thing 
     echo '<a href="'.$_SERVER[REQUEST_URI].'&l=en">English</a>'; 
     echo '<a href="'.$_SERVER[REQUEST_URI].'&l=sk">Slovensky</a>'; 
     echo '<a href="'.$_SERVER[REQUEST_URI].'&l=de">Deutsch</a>'; 
       //?l=lang changes to &l=lang 
     } 
    else 
     { 
       //Link with normal ?l=lang, cause page does not use another $_GET[...] 
      echo '<a href="?l=en">English</a>'; 
      echo '<a href="?l=sk">Slovensky</a>'; 
      echo '<a href="?l=de">Deutsch</a>';  
     } 
?> 
相關問題