回声不工作

时间:2014-03-11 16:42:53

标签: php cakephp echo

我正在尝试使用cakephp和twitter bootsrap制作网站。对于我正在制作的画廊,我正在尝试使用foreach显示多个图像,但它们根本不显示。一切正常,foreach和可变数据,但回声不显示任何东西。有人可以帮忙吗? 提前致谢。 (代码来自我的show_images.ctp视图)

    <table >
<tr>

<?php
$i=0;
foreach( $gallery_images as $gallery_image ):?>
<td align=center>
  <?php echo "<a id=\"single_1\" href=\"test/".$gallery_image['GalleryImage']['path']." ";?>
  <?php echo "<img src=\"test/".$gallery_image['GalleryImage']['path'].", alt=\"".$gallery_image['GalleryImage']['path']."";?>
  <?php echo "</a>";?>

    </td>
    <?php $i++;?>

    <?php
        if($i==4){
            echo "</tr><tr>";
            $i=0;   
        }
    ?>
<?php endforeach ?>
</tr>

1 个答案:

答案 0 :(得分:0)

你还没有在回声中关闭你的标签,试着改变这个:

<?php echo "<a id=\"single_1\" href=\"test/".$gallery_image['GalleryImage']['path']." ";?>
  <?php echo "<img src=\"test/".$gallery_image['GalleryImage']['path'].", alt=\"".$gallery_image['GalleryImage']['path']."";?>
  <?php echo "</a>";?>

到此:

<?php echo '<a id="single_1" href="test'.$gallery_image['GalleryImage']['path'].' >';?>
  <?php echo '<img src="test'.$gallery_image['GalleryImage']['path'].'" alt="'.$gallery_image['GalleryImage']['path'].'" />';?>
  <?php echo '</a>';?>
相关问题