Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-22-2008, 09:08 AM   PM User | #1
niko-cola
New Coder

 
Join Date: Apr 2008
Posts: 46
Thanks: 1
Thanked 0 Times in 0 Posts
niko-cola is an unknown quantity at this point
I have to add an image from a folder - IMG SRC the database

I have to add an image which is saved in a folder.
The folder and name are specified in the database in the $path field.
I want to not display anything if there is no data in the $path field.
And to display the image if the address is specified in $path.

This code is not working...don't know why...

PHP Code:
<img src='<? if (!$path) { } else { echo $path ?>'>

Last edited by niko-cola; 05-22-2008 at 09:10 AM.. Reason: grammar error
niko-cola is offline   Reply With Quote
Old 05-22-2008, 09:14 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
PHP Code:
if($path)
 echo 
"<img src=\"{$path}\" alt=\"\"/>"
?
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 05-22-2008, 10:26 AM   PM User | #3
syosoft
Regular Coder

 
Join Date: Sep 2006
Location: Vermont, USA
Posts: 154
Thanks: 0
Thanked 6 Times in 6 Posts
syosoft is an unknown quantity at this point
PHP Code:
<?php echo trim($path) != '' '<img src="'.$path.'" alt="">' ''?>
__________________
Active PHP/MySQL application developer available for immediate work.
syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready
syosoft is offline   Reply With Quote
Old 05-22-2008, 10:39 AM   PM User | #4
niko-cola
New Coder

 
Join Date: Apr 2008
Posts: 46
Thanks: 1
Thanked 0 Times in 0 Posts
niko-cola is an unknown quantity at this point
I got syntax errors because of ".
niko-cola is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:24 AM.


Advertisement
Log in to turn off these ads.