IF Statement to display image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mrquestions
    New Member
    • Nov 2006
    • 1

    IF Statement to display image

    Hey, new to the forum, have looked everywhere for some information of the following query but can't find it anywhere...

    Within a site I am building a division calls on an include function to display a webpage ($page), so only the one template page is used throughout the entire site. It has been all smooth sailing up until I wanted to have a MouseOver image (image.src), become "selected" upon requesting its specific page.

    [PHP]<? if ($page = 'pagename') {
    echo
    '<img src="imageM.jpg name="image" border="0">';
    }
    else {
    echo
    '<a onMouseOver="im age.src='imageM .jpg';" onMouseOut="ima ge.src='image.j pg';"><img src="image.src name="image" border="0"></a>';
    }
    ?>[/PHP]


    It is within a table division if that means anything...
    oh, and its all on one line, not like above...

    Cheers
  • TheMadMidget
    New Member
    • Oct 2006
    • 98

    #2
    [PHP]<? if ($page = 'pagename') {
    echo
    '<img src="imageM.jpg " name="image" border="0">';
    }
    else {
    echo
    '<a onMouseOver="im age.src=&#39ima geM.jpg&#39;" onMouseOut="ima ge.src=&#39imag e.jpg&#39;"><im g src="image.src" name="image" border="0"></a>';
    }
    ?>[/PHP]
    I changed the internal 's to &#39 . This allows the html to have the apostrophe but doesn't interfere with the PHP code.
    Also in both <img> tags, the src attribute only had a quotation before it, non after it, so I fixed that too.

    Comment

    Working...