ruud2000 Posted March 6, 2008 Share Posted March 6, 2008 Hi, I have a question, I try to show a different picture my left table depending on the url, I mean something like this: <?php if (url=="index.php?option=com_content&view=frontpage&Itemid=1") { echo ('<img src=\"templates/RBL/images/webmaster.gif\" alt=\"Administrator\" border="0" />'); } ?> <?php if (path=="index.php?option=com_content&view=frontpage&Itemid=2") { echo ('<img src=\"templates/RBL/images/global.gif\" alt=\"Administrator\" border="0" />'); } But this does'nt work, what can I do? Greetings Ruud ?> Link to comment https://forums.phpfreaks.com/topic/94804-if-statement-with-url/ Share on other sites More sharing options...
revraz Posted March 6, 2008 Share Posted March 6, 2008 You need to define url and path. Right now they are constants, did you define them? Link to comment https://forums.phpfreaks.com/topic/94804-if-statement-with-url/#findComment-485517 Share on other sites More sharing options...
Caesar Posted March 6, 2008 Share Posted March 6, 2008 I'm assuming you either are using constants or aren't sure how to define the url..... <?php function get_image($id) { switch($id) { case '1': $image = 'webmaster.gif'; break; case '2': $image = 'global.gif'; break; } return $image; } $id = $_GET['id']; // This would be the value in http://yourdomain.com/index.php?id=123 $img = 'templates/RBL/images/'.get_image($id); echo '<img src="'.$img.'" order="0" />'; ?> Possibly something like that.... Link to comment https://forums.phpfreaks.com/topic/94804-if-statement-with-url/#findComment-485525 Share on other sites More sharing options...
ruud2000 Posted March 6, 2008 Author Share Posted March 6, 2008 I will try it, now I go to sleep Thanks very much. Link to comment https://forums.phpfreaks.com/topic/94804-if-statement-with-url/#findComment-485550 Share on other sites More sharing options...
ruud2000 Posted March 7, 2008 Author Share Posted March 7, 2008 I found a simple solution: <?php $url = $_GET['Itemid']; if ($url == '1') { echo ('<img src="templates/RBL/images/webmaster.gif" border="0" />'); } else { echo "geen plaatje"; } ?> Thanks for the help Link to comment https://forums.phpfreaks.com/topic/94804-if-statement-with-url/#findComment-485632 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.