sam127 Posted May 13, 2010 Share Posted May 13, 2010 Hi, i am designing an international website with different languages as button or flag. i have all my factlets in diff languages saved in database already, all i need now is a function that will load my selected language on the click button or flag to the front page,each time the button or flag is click, i wont corresponding language to language to load from database. here is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="robots" content="noindex, nofollow" /> <style type="text/css"> div.container{ width:100%; background-color:#e7ffcd;} div.header{ background-color:#700000; font-size:1.5em; padding:0.4em 1.5em 0.4em 1.5em; border-style:outset;} div.nav{ background-color:#600000; width:8em; min-height:51.5em; em; float:left;} div.content{ background-color:#383838 ; margin-left:8em; min-height:50em; padding:0.4em 1.5em 0.4em 1.5em; border-style:inset; line-height:150%;} div.footer{ background-color:#700000; clear:left; padding:0.4em 1.5em 0.4em 1.5em; border-style:outset;} div.nav-button{ margin:5% 5% 5% 15%;} div.nav-button-mark{ background-color:#ffaaaa; margin:5% 0% 5% 15%;} </style> <title>Framework: DIV based</title> </head> </style> <title>Framework: DIV based</title> </head> <body> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="robots" content="noindex, nofollow" /> <title> PHP & MySQL </title> </head> <body> <center> <div class="container"> <div class="header" align=center> ADAPTIVE INTERNATIONALISED WEBSITE <marquee direction="left" height="26" scrolldelay="90" scrollamount="6" behavior="alternate" loop="0";" id="Marquee1"><font style="font-size:13px" color="#00FF00" face="Arial Black"><i>University Library in Chinese, Japanese, French and Afrikaans.</i></font></marquee> <div class="header" align=left> <font style="font-size:15px" color="#FF" face="Tahoma"> <select name="Languages" size="1" id="Combobox1" onselect="ShowObject('Combobox1', 1);return false;"> <option type='selected' method='POST' name='$row[3]'>French</option> <option type='selected' method='POST' name='$row[1]'>Chinese(simplified)</option> <option type='selected' method='POST' name='$row[2]'>Japanese</option> <option type='selected' method='POST' name='$row[0]'>English</option> </select> <input type="submit" id="Button1" name="Button1" value="GO" style="postion:absolute;left:82px;width:35px;height:24px;font-family:Tahoma;font-size:13px;z-index:0"> <?php /** * Just add this in your page where you * want the date/time to appear * * For more configuration options look * in the PHP manual at http://uk2.php.net/date */ // Displays in the format Saturday, November 22, 2003 11.38 echo date("l, F d, Y H:i " ,time()); ?> </font> </div> <div class="nav"> <!-- You may want to include the php echo $_SERVER['PHP_SELF'] so that one has the full URL rather than leave it to the Browser to complete --> <div class="nav-button"><a href='?page=home'>home</a></div> <div class="nav-button"><a href='href='?page=page1'>gallery</a></div> <div class="nav-button"><a href='?page=page2'>business</a></div> <div class="nav-button"><a href='?page=page3'>contact us</a></div> </div> <div class="content"> <?php "../../group01.php" ; $mysql_hostname="co-project.lboro.ac.uk"; $mysql_username="group05"; $mysql_password="gmp66env"; $link_id_resource=mysql_connect($mysql_hostname, $mysql_username, $mysql_password); if($link_id_resource === false){exit("Cannot make connection to the MySQL server");} mysql_query("SET NAMES 'utf8';", $link_id_resource); //utf8 stuff // Selecting a MySQL database $mysql_database="group05"; $database_selected=mysql_select_db($mysql_database,$link_id_resource); mysql_query("SET NAMES 'utf8';", $link_id_resource); //utf8 stuff echo '<h2>• UNIVERSITY LIBRARY •</h2>'; $sql_query = "SELECT Chinese FROM `Table`"; $result=mysql_query($sql_query); while ($row=mysql_fetch_row($result)){ echo $row[0]."<br/>"; }; mysql_close($link_id_resource); ?> </div> <div class="text"> <font style="font-size:11px" color="#FF" face="Tahoma"> © 2010 GroupOne. All right reserved </font> </div> </div> </body> </html> urgent help needed as i need to submit it soon....thanks Link to comment https://forums.phpfreaks.com/topic/201642-help-phpmysql-website-problem/ Share on other sites More sharing options...
andrewgauger Posted May 13, 2010 Share Posted May 13, 2010 $sql_query = "SELECT Chinese FROM `Table`"; changes to: $sql_query = "SELECT {$_GET['language']} FROM `Table`"; and you request the page using: page.php?language=Chinese You then need to build out the form (which you are missing). Just replace this: <select name="Languages" size="1" id="Combobox1" onselect="ShowObject('Combobox1', 1);return false;"> <option type='selected' method='POST' name='$row[3]'>French</option> <option type='selected' method='POST' name='$row[1]'>Chinese(simplified)</option> <option type='selected' method='POST' name='$row[2]'>Japanese</option> <option type='selected' method='POST' name='$row[0]'>English</option> </select> <input type="submit" id="Button1" name="Button1" value="GO" style="postion:absolute;left:82px;width:35px;height:24px;font-family:Tahoma;font-size:13px;z-index:0"> with: <form action="page.php" method="get"> <select name="language" size="1" id="Combobox1""> <option name='French'>French</option> <option name='Chinese'>Chinese(simplified)</option> <option name='Japanese'>Japanese</option> <option name='English'>English</option> </select> <input type="submit" id="Button1" name="Button1" value="GO" style="postion:absolute;left:82px;width:35px;height:24px;font-family:Tahoma;font-size:13px;z-index:0"> </form> Also, replace every instance of page.php with the name of your page. Verify that the entries in your MySQL match the languages I have hard coded. Link to comment https://forums.phpfreaks.com/topic/201642-help-phpmysql-website-problem/#findComment-1057815 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.