bluedogatdingdong Posted February 25, 2005 Share Posted February 25, 2005 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 Quote Link to comment https://forums.phpfreaks.com/topic/2175-dynamic-images/ Share on other sites More sharing options...
DFWBounce Posted March 9, 2005 Share Posted March 9, 2005 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) Quote Link to comment https://forums.phpfreaks.com/topic/2175-dynamic-images/#findComment-7215 Share on other sites More sharing options...
jesserules Posted March 12, 2005 Share Posted March 12, 2005 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. Quote Link to comment https://forums.phpfreaks.com/topic/2175-dynamic-images/#findComment-7240 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.