Jump to content

Archived

This topic is now archived and is closed to further replies.

bluedogatdingdong

dynamic images

Recommended Posts

I'm sure the code must be quite simple, but I can't find an example anywhere.

 

All I want to do is instead of displaying the image name eg boat.jpg actually display the image.

 

Any help much appreciated.

 

Jayne

Share this post


Link to post
Share on other sites

I'm not sure if you're asking how to display the image using php instead of html but if so... this is how to do it:

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

[span style=\"color:#0000BB\"]<?php

 

[/span][span style=\"color:#007700\"]echo ([/span][span style=\"color:#DD0000\"]\"<img src=\\"[/span][span style=\"color:#0000BB\"]boat[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]jpg[/span][span style=\"color:#007700\"]&[/span][span style=\"color:#FF8000\"]#092;\">\");

 

[/span][span style=\"color:#0000BB\"]?>[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

You have to use the \ before the quotes in the html so that the server understands that they are not part of the php code. Hope this helps. (note: in the code above, the group of characters after "jpg" and before ">"); should actually be a forward slash "\".... I'm not sure why it wouldn't show up as a forward slash)

Share this post


Link to post
Share on other sites

if you want to display an image depending on a var, do it like this:

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

[span style=\"color:#0000BB\"]<?php

$image [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"image.jpg\"[/span][span style=\"color:#007700\"];

echo [/span][span style=\"color:#DD0000\"]\"<img src=$image>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]?>

[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

the reason you do it like this is that PHP outputs in the form of HTML. in HTML typing in <img src=image.jpg> will include the image, so that's how you do it in PHP.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.