imperium2335 Posted May 16, 2009 Share Posted May 16, 2009 Hi, Im trying to set something up where the user can choose a language using session and a hyperlink that changes the variable. <?PHP $_SESSION['lang'] = "En" ; ?> So when they click, say french, the above var is now "Fr". ive tried this: <a href="cake-photos.html?lang=Fr">French</a> But it doesn't work. Please help. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/158355-change-variable-using-hyperlink/ Share on other sites More sharing options...
papaface Posted May 16, 2009 Share Posted May 16, 2009 session_start(); switch ($_GET['lang']) { case "En"; $_SESSION['lang'] = "En"; break; case "Fr"; $_SESSION['lang'] = "Fr"; break; default: $_SESSION['lang'] = "En"; } Link to comment https://forums.phpfreaks.com/topic/158355-change-variable-using-hyperlink/#findComment-835183 Share on other sites More sharing options...
nirmalsinghkps Posted May 16, 2009 Share Posted May 16, 2009 really this ques sounds bad.........i think Link to comment https://forums.phpfreaks.com/topic/158355-change-variable-using-hyperlink/#findComment-835199 Share on other sites More sharing options...
Ken2k7 Posted May 16, 2009 Share Posted May 16, 2009 What's with the semi-colons in the cases? session_start(); switch ($_GET['lang']) { case 'Fr': $_SESSION['lang'] = "Fr"; break; case 'En': default: $_SESSION['lang'] = "En"; } Link to comment https://forums.phpfreaks.com/topic/158355-change-variable-using-hyperlink/#findComment-835259 Share on other sites More sharing options...
papaface Posted May 16, 2009 Share Posted May 16, 2009 What's with the semi-colons in the cases? session_start(); switch ($_GET['lang']) { case 'Fr': $_SESSION['lang'] = "Fr"; break; case 'En': default: $_SESSION['lang'] = "En"; } Oops typo lol. Dunno why I did them all with a semi-colon and then with a colon for the default ??? lol Link to comment https://forums.phpfreaks.com/topic/158355-change-variable-using-hyperlink/#findComment-835306 Share on other sites More sharing options...
imperium2335 Posted May 17, 2009 Author Share Posted May 17, 2009 Thanks for your replys, this is what i used in the end: session_start(); if(isset($_GET['lang'])) { $_SESSION['lang'] = $_GET['lang']; setlocale(LC_ALL, $_SESSION['lang']); } else { setlocale(LC_ALL, $_SESSION['lang']); } echo $_SESSION['lang']; ?> I am unfamilier with setlocale though. Out of interest, does anyone know the default font type Arabic users use? Link to comment https://forums.phpfreaks.com/topic/158355-change-variable-using-hyperlink/#findComment-835678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.