[RESOLVED] correct syntax for img within php loop?
Results 1 to 3 of 3

Thread: [RESOLVED] correct syntax for img within php loop?

  1. #1
    Member
    Join Date
    Apr 2012
    Posts
    38

    resolved [RESOLVED] correct syntax for img within php loop?

    hello,

    I've got a media query which then loops the results, but the result is a image filepath, which i need displayed within an img tag to actually show the image, but cant figure out the correct syntax for it

    PHP Code:
    <?
    $result
    =mysql_query("SELECT filepath FROM uploads");  
    while(
    $row mysql_fetch_array($resultMYSQL_BOTH)){
         <
    img src="<? echo $row['filepath']?>"/>
         echo 
    "<br />";
    }
    ?>

    <img src="<? echo $row['filepath']?>"/>
    the bottom <img src= works, but i cant figure out how to add it inside a loop
    any help really appreciated

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,432
    You either need to escape out of PHP mode (e.g. add a '?>' closing tag before the HTML output) or simply use echo to echo out the HTML markup. Either way, you can't throw HTML markup in the middle of PHP code and expect PHP to know what to do with it.

  3. #3
    Member
    Join Date
    Apr 2012
    Posts
    38
    thanks you all sorted

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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