Rabbar Posted January 17, 2008 Share Posted January 17, 2008 Hi. I am from Iceland and I am creating a multilanguage webpage with php. I will have religious "quotes" on it in many languages. sample: If I come from Iceland the page loads up in icelandic and if I come from english speaking countrys the page loads up in english. I have index file and it looks like this " <!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"> <head> <meta name="keywords" content="" /> <meta name="description" content="" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title></title><link rel="stylesheet" href="adal.css" type="text/css" /><style type="text/css"> </head> <body> <?php // $IPaddress=$_SERVER['REMOTE_ADDR']; $two_letter_country_code=iptocountry($IPaddress); function iptocountry($ip) { $numbers = preg_split( "/\./", $ip); include("ip_files/".$numbers[0].".php"); $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]); foreach($ranges as $key => $value){ if($key<=$code){ if($ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;} } } //* HERE IS WHERE THE PROBLEM STARTS If I come from iceland I want the page "careframe.is.php" to load up inside the "iframe src="careframe.is.php" see the country code is "is" and if I come from english speaking countrys like england, usa, australia I want the file "careframe.en.php" to load up inside the "iframe" This "$two_letter_country_code" must be placed inside the "iframe src" Like: "iframe src="careframe.$two_letter_country_code.php" if ($two_letter_country_code == "IS")return "is"; //target=careframe.is.php in iframe window if ($two_letter_country_code == "EN,US,GB,AU")return "en"; //target=careframe.en.php in iframe window if ($two_letter_country_code == "DE")return "de"; //target=careframe.de.php in iframe window if ($two_letter_country_code == "AR,BR,CH")return "es"; //target=careframe.es.php in iframe window } ?> <table width="770" height="580" border="0" align="center" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="770" height="580" valign="top"> <iframe src="careframe.is.php" name="careframe.is" scrolling="no" frameborder="0" id="iframe"></iframe> </td> </tr> </table> </body> </html> " here is the page in icelandic http://www.galdan.org/ and here is how it will look like in english http://www.galdan.org/careframe.en.php Can anyone please help me fix this? please!!! Link to comment https://forums.phpfreaks.com/topic/86462-solved-two_letter_country_code-and-target/ Share on other sites More sharing options...
Rabbar Posted January 17, 2008 Author Share Posted January 17, 2008 I figured it out :) " <?php // $IPaddress=$_SERVER['REMOTE_ADDR']; $two_letter_country_code=iptocountry($IPaddress); function iptocountry($ip) { $numbers = preg_split( "/\./", $ip); include("ip_files/".$numbers[0].".php"); $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]); foreach($ranges as $key => $value){ if($key<=$code){ if($ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;} } } if ($two_letter_country_code=="US" || $two_letter_country_code=="GB" || $two_letter_country_code=="UK" || $two_letter_country_code=="AU")include('careframe.en.php'); if ($two_letter_country_code == "IS")include('careframe.is.php'); } ?> " Link to comment https://forums.phpfreaks.com/topic/86462-solved-two_letter_country_code-and-target/#findComment-441897 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.