I have the following code that is inserted into a Wordpress theme file. As you can imagine, it's not outputting correctly. I am no coder so I need some help with this. The following code should (hopefully) determine the country a visitor is from and display the appropriate banner to them. <?php $country = wp_ozh_getCountryName(0) ; switch ($country) { case "Canada" : <a target="_blank" href="http://www.affiliate.com/fs-bin/click?id=referrer_ID"><IMG alt="Canadian Banner" border="0" src="http://images.affiliate.com/outsidebanners/Homepage-120X600.gif"></a><IMG border="0" width="1" height="1" src="http://ad.affiliate.com/fs-bin/show?id=referrer_ID">; break; default : <a target="_blank" href="http://www.affiliate.com/fs-bin/click?id=referrer_ID"><IMG alt="American Banner" border="0" src="http://images.affiliate.com/outsidebanners/Homepage-120X600.gif"></a><IMG border="0" width="1" height="1" src="http://ad.affiliate.com/fs-bin/show?id=referrer_ID">; } ?> PHP: The code that determines the country is working fine when I substitute the html banner links with the echo command. I just need someone to tell me how to include the html code with the correct syntax inside the php tags. Thanks!
try this <?php $country = wp_ozh_getCountryName(0) ; switch ($country) { case "Canada" : Print "<a target=\"_blank\" href=\"http://www.affiliate.com/fs-bin/click?id=referrer_ID\"><IMG alt=\"Canadian Banner\" border=\"0\" src=\"http://images.affiliate.com/outsidebanners/Homepage-120X600.gif\"></a><IMG border=\"0\" width=\"1\" height=\"1\" src=\"http://ad.affiliate.com/fs-bin/show?id=referrer_ID\">"; break; default : Print "<a target=\"_blank\" href=\"http://www.affiliate.com/fs-bin/click?id=referrer_ID\"><IMG alt=\"American Banner\" border=\"0\" src=\"http://images.affiliate.com/outsidebanners/Homepage-120X600.gif\"></a><IMG border=\"0\" width=\"1\" height=\"1\" src=\"http://ad.affiliate.com/fs-bin/show?id=referrer_ID\">"; } ?> PHP: That should work...
Definitely do it the way kishore415 said. When I was first learning PHP I used echo and print to insert HTML code and now I run into a lot of problems with trying to debug and work with all that old code.