我在以下代码中执行了 2 个单独的 foreach 循环。最后,在第二个 foreach 循环之后,我有 $row->websiteURL 输出。问题是 $row->websiteURL 是第一个循环的一部分。因此,当我运行代码时出现以下错误:
遇到 PHP 错误
严重性:通知
消息:未定义的属性:stdClass::$websiteURL
文件名:views/projects.php
行号:135
" 目标="_blank">
在第二个 foreach 完成后,我将如何继续第一个 foreach 循环?
<table style="width: 41%">
<?php $query = $this->db->query("SELECT * FROM projects ORDER BY idprojects DESC");
foreach ($query->result() as $row) { ?>
<tr>
<td style="height: 15px">
<div class="auto-style2">
<em><span class="auto-style1"><?=$row->projectName?></span></div>
<table cellpadding="5" style="width: 535px; height: 66;">
<tr>
<td class="box1" style="height: 49px; width: 800px;">
<table cellpadding="0" cellspacing="0" style="width: 466px; height: 185px">
<!-- MSTableType="layout" -->
<tr>
<td valign="top" style="width: 225px">
<em>
<table style="width: 100%">
<tr class="box1">
<td class="innerbox" style="height: 88px"><em><span class="text1">Project name</span>:
<span class="underlined-link"><?=$row->projectName?></span><br>
<span class="text1">Description</span>: <?=$row->projectDesc?><br><span class="text1">Start
date</span>: <?=$row->startDate?><br><span class="text1">Finised date</span>:
<?=$row->finishedDate?><br><span class="text1">Created for</span>:
<?=$row->createdFor?><br><span class="text1">Contributers</span>:
<span class="underlined-link"><?=$row->contributors?></span></em></td>
</tr>
</table>
</em></td>
<td style="width: 12px"> </td>
<td valign="top" style="height: 185px; width: 229px">
<em>
<?php $query = $this->db->query("SELECT * FROM screenshots ORDER BY idscreenshot DESC");
foreach ($query->result() as $row) { ?>
<img alt="" src="<?=$row->screenshotURI?>" width="231" height="187"></em> </td>
</tr>
<?php } ?>
</table>
<br>
<a style="text-decoration:none" href="<?=$row->websiteURL?>" target="_blank"><div class="link1">
View This Product</div></a>
</td>
</tr>
</table>
</em></td>
</tr>
<?php } ?>
</table>