1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

PHP - dynamicly inserting table elements

Discussion in 'Mac Programming' started by larswik, Jun 29, 2012.

  1. larswik, Jun 29, 2012
    Last edited: Jun 29, 2012

    macrumors 65816

    I am moving a long with my project and came into a snag again. I have a number of clients which have images in a folder from 3 to 10 photos. I am tryign to create a dynamic table in HTML with PHP code embedded to get the right number of photos in to the table.

    If I use this line of code all by it's self in a table it works fine and the photo displays with the PHP tags.
    <TD><IMG SRC=[B]"<?php echo $linksArray[0]; ?>"[/B] HEIGHT=213 WIDTH=320 ALIGN=left HSPACE=10 VSPACE=10><TD>
    But if I wrap this in php tags to echo out the code the image will not show?

    	echo '<TD><IMG SRC= " <?php echo $linksArray[0]; ?>" HEIGHT=213 WIDTH=320 ALIGN=left HSPACE=10 VSPACE=10></TD>';
    The end result with be a "foreach" loop for each photo that is in the client folder.
  2. macrumors 68040


    You can't nest the php tags.

    Use a period to concatenate:

    echo '<TD><IMG SRC="'.$linksArray[0].'" HEIGHT=213 WIDTH=320 ALIGN=left HSPACE=10 VSPACE=10></TD>';
    or this will work:

    echo "<TD><IMG SRC=\"{$linksArray[0]}\" HEIGHT=213 WIDTH=320 ALIGN=left HSPACE=10 VSPACE=10></TD>";
  3. macrumors 65816

    Gotcha, that fixed the problem.

    Good to know


Share This Page