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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

basic php problem

Status
Not open for further replies.

lennon123

Technical User
Apr 12, 2008
19
GB
hi there,
really simple one... how do i display an image using php? Im using a case switch and all i want it to do is display an image based on a variable that is set. know the case switch is working cuz its works with a string but cant get an image to print. Anyone help?
 
just echo out the html to the browser

Code:
switch ($_GET['somevar']){
  case 1:
    echo "<img src=\"image1.png\" />";
    break;
  case 2:
    ...etc
}
 
Today I am right behind jpadie .... :cool:

Two things:
(1) If escaping the characters confuse you, try combining the quotes. Use echo '<img src="image1.png" />';

(2) Simply echoing something to the screen does not guarantee it will be visible; you MUST make sure it is set in a visible area of your page and that you do not have layers sitting on top of it (if using <div> tags) or that it does not get lost on the background color - Make sure there is contrast.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top