?
Solved

PHP Displaying Images ??

Posted on 2003-03-20
9
Medium Priority
?
200 Views
Last Modified: 2009-07-29
Hello,
I want <img src="some.php"> to display an image .. can someone gimme an example code for some.php? Thanks!
0
Comment
Question by:lexxwern
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 1

Expert Comment

by:Thunder27
ID: 8174062
Are you trying to select from a list of images?  If so, using some PHP code to define a variable would work...

i.e.

switch ($myvar)
     {
          case "1" : $pic = "pic1.jpg";
                break;
          case "2" : $pic = "pic2.jpg";
                break;
          case "3" : $pic = "pic3.jpg";
                break;
     }

echo "<img src=\"$pic\">";


Of course, there are a million ways to do this depending on what you're trying to achieve.
0
 
LVL 4

Accepted Solution

by:
girish_nair earned 1000 total points
ID: 8175187
I hope you want something like this.

<img src='somescript.php?image=abc.gif'>

then your somescript.php should  work like this

<?
header("Content-type: image/gif"); send the header

////Read the content from $image and echo it///

?>

You can find details in the manual (on reading a file, sending headers)

Cheers,
Girish
0
 
LVL 15

Expert Comment

by:VGR
ID: 8175248
combine both suggestions and you've tyour solution

note that using a link <img src='somescript.php?image=abc.gif'> is completely ridiculous per se : just write <img src="abc.gif"> ;-))
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 4

Expert Comment

by:girish_nair
ID: 8175487
Hi,

>> note that using a link <img src='somescript.php?image=abc.gif'> is completely ridiculous per se : just write <img src="abc.gif"> ;-))


I think lexxwern wanted this :-)
The snippet to display image from php script ::--))

Cheers!!
0
 
LVL 12

Author Comment

by:lexxwern
ID: 8178922
this was it.. thanks girish!
PS: India V Australia this sunday!!
0
 
LVL 15

Expert Comment

by:VGR
ID: 8179390
rather strange IMHO 8-)

The data passed to somescript.php should be an image ID or nothing (random image shower) ; for what purpose (à part from logging images' displays...) to passe the image name to a shower rather than show it directly ? Hiding the image path perhaps ? (that's fake, 'cause the showed image will show the entire server's path to it in its properties)
0
 
LVL 12

Author Comment

by:lexxwern
ID: 8179416
Im not going to use any query string, nor am i interested in hiding the path (i know better!) ..

I am basically working on a user tracking script, so my end users will just have to put the image tags in their page, and my script will do the tracking and display the image..

cheers!
0
 
LVL 15

Expert Comment

by:VGR
ID: 8179433
fine then
0
 
LVL 4

Expert Comment

by:girish_nair
ID: 8181895
Enjoy coding! Enjoy cricket!
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question