Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Image Load

Status
Not open for further replies.

ironmunk

Technical User
Aug 21, 2001
51
CA
I am trying to do something which I'm not even sure can be done.

I want php to load an image if certain conditions are met.

below is the code i'm playing with. Can someone please provide feedback

<?php
$x=1;

if ($x == 1) <IMG SRC=&quot;images/ComingSoon_Middle1_Mid.jpg&quot; WIDTH=304 HEIGHT=130 ALT=&quot;&quot;>
?>

so if $x=1 then I want the image to load.. else I want another image to load (not in the code yet).
 
Code:
<?php
if ($x == 1) {
echo &quot;<IMG SRC=\&quot;images/ComingSoon_Middle1_Mid.jpg\&quot; WIDTH=\&quot;304\&quot; HEIGHT=\&quot;130\&quot; ALT=\&quot;\&quot;>&quot; ; 
}
else {
echo &quot;<IMG SRC=\&quot;images/someotherimage.jpg\&quot; WIDTH=\&quot;304\&quot; HEIGHT=\&quot;130\&quot; ALT=\&quot;\&quot;>&quot; ; 
}

?>

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Thank you. It worked.

Now is there a way to set a global variable? ie.

<php

set variable X here

?>

HTML CODE

<php

USE variable X here

?>

Is that possible or do I need to use a special variable?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top