Jump to content

if statement with url


ruud2000

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.