PHP foreach - 在同一页面中创建多个搜索

时间:2015-09-03 06:59:12

标签: php foreach

首先,我是一个完整的PHP新手。 其次,下面是php标题以及相同html页面中2个照片灯箱的相应递归命令。

没有行

 getRecords()as $ Title_row){?>

页面显示正确显示灯箱外部数据库表中的第一张图片。

然而,当我添加以下行以添加每个表中的所有其他条目时

 getRecords()as $ Title_row){?>

页面变为白色,浏览器html返回为空。

因为我真的不明白我在做什么,所以我被困住了。任何建议都会非常受欢迎。

if(list.Count!=1)
{
    //log
    Console.WriteLine("The collection does not contain exactly one element.");
}
var item = list.FirstOrDefault();

1 个答案:

答案 0 :(得分:1)

你错过了结束括号:

<?php foreach($Title_result->getRecords() as $Title_row){ ?>
                <div class="hide">
                       <a data-group="gallery-1" data-caption="<?php echo $Title_row->getField('Title'); ?>" href="<?php echo $Title_row->getField('Pic_location'); ?>"></a>
                </div>
<?php }?>

<?php foreach($Title2_result->getRecords() as $Title2_row){ ?>
                <div class="hide">
                       <a data-group="gallery-2" data-caption="<?php echo $Title2_row->getField('Title'); ?>" href="<?php echo $Title2_row->getField('Pic_location'); ?>"></a>
                </div>
<?php }?>