aerophilia Posted May 30, 2008 Share Posted May 30, 2008 Hi, php newb here. Quick "easy" question for you. It has been hurting my head this last hour. What I want to do: if my URL has "?country_id=2" have my text appear on the page. if(!isset($_GET['country_id'])){ if($country_id=="2"){ echo $europe_austria_txt; } } for further information here's "$europe_austria_text" $europe_austria_txt=" <br /> Here will be some great text about the wonderful place they call Austria<br /> "; Link to comment https://forums.phpfreaks.com/topic/107962-solved-ifisset_getcountry_id-head-hurts/ Share on other sites More sharing options...
GingerRobot Posted May 30, 2008 Share Posted May 30, 2008 1.) You dont need the ! sign. That makes the statement read the opposite to what you want. 2.) Unless you extracted $country_id from the URL previously, then that is unset. 3.) You can do it all with one if statement: if(isset($_GET['country_id']) && $_GET['country_id'] == 2){ echo $europe_austria_txt; } Also, if you enclose your string in double quotes, then you can use \n to make a new line, rather than spreading it across multiple lines: $europe_austria_txt="\n<br />Here will be some great text about the wonderful place they call Austria<br />\n"; Link to comment https://forums.phpfreaks.com/topic/107962-solved-ifisset_getcountry_id-head-hurts/#findComment-553381 Share on other sites More sharing options...
aerophilia Posted May 30, 2008 Author Share Posted May 30, 2008 Thanks Ben thats perfect. I can see exactly where I was going wrong there now. Link to comment https://forums.phpfreaks.com/topic/107962-solved-ifisset_getcountry_id-head-hurts/#findComment-553648 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.