Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2008
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    PHP Code:
    if($path)
     echo 
    "<img src=\"{$path}\" alt=\"\"/>"
    ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Sep 2006
    Location
    Vermont, USA
    Posts
    154
    Thanks
    0
    Thanked 6 Times in 6 Posts
    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

  • #4
    New Coder
    Join Date
    Apr 2008
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I got syntax errors because of ".


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •