Please help. I can not figure out how to add a simple link to an image when the image is called through PHP. I have tried making it work a number of ways but I am only intermediate in HTML and still trying to learn PHP basics.

The code is:

<div id="mainleft">
<h2>Place CMG Title Header Here</h2>
<img src="<?php echo get_bloginfo('url') ?>/serv67/cmg2/img/blog2.jpg" >

Thank you for your help! I just want to use the image as a link to another page.

Respects,
cmgdev

I guess you mean this:

<a href="http://www.google.com">
<img src="<?php echo get_bloginfo('url') ?>/serv67/cmg2/img/blog2.jpg" alt="pic" />
</a>

Thank you buddylee17. It is sad how easy it is to be so ignorant of something so simple. I was trying to link from inside the php tag and I didn't ever think to place it right outside of it.

I appreciate your help.

Hi please I would like to know the code for inserting images in php website

Hi please I would like to know the code for inserting images in php website

there is none, PHP is a server side language you will need to echo out the image tag as you would write it using html

there is none, PHP is a server side language you will need to echo out the image tag as you would write it using html

Now that's not entirely true, wrivera. There's always this tag:

<?php // Insert an image 
?>
<img src="imagename.jpg">
<?php // End image insertion 
?>

See? ;)

you can only use a echo like
echo "<img src=file address>";

Hi, I need help. There will be a lot of image on my webpage and I wish to link them to a php page. But how do I specify that the image you click will fetch that particular image data.

Thanks.

Can you clarify what you mean by image data?

Do you mean show an image that links you to another page? You can do this using a combination of anchor and image links. Here is an example...

  <a href="targetPage.php"> <img src="image.jpg" /> </a>

Or do you mean the PHP page is generated the image itself? Please clarify.

By the way, you should start your own thread rather than hijacking someone else's. it just good etiquette.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.