我的代码有问题。我有这样的代码:
<?php
include('php/SelectHistory.php');
include('php/SelectSmallHistoryUser.php');
include('php/SelectSmallHistoryProject.php');
include('php/SelectSmallHistoryFunctionality.php');
$newHistoryRow = SelectHistory();
echo "<table width='100%'>";
if (count($newHistoryRow) > 0)
{
foreach ($newHistoryRow as $current)
{
$chosenUser = SelectSmallHistoryUser($current->userID);
$chosenProject = SelectSmallHistoryProject($current->projectID);
$chosenFunctionality = SelectSmallHistoryFunctionality($current->functionalityID);
echo "<tr>";
echo "<td>" . $chosenUser->fullName . " was busy with " . $chosenFunctionality->functionalityName . " on " . $chosenProject->projectName . " at " . $current->lastModifiedDate;
echo "</tr>";
unset($chosenUser);
unset($chosenProject);
unset($chosenFunctionality);
}
}
else
{
echo "<tr><td>No History To Display.</td></tr>";
}
echo "</table>";
?>
我遇到的问题是在循环中,它声明了一个驻留在类中的方法。现在因为它正在处理来自数据库的数据,如果事物的数量超过一个,我会收到“已声明的类”错误。
有没有办法可以解决这个问题,或者我可以使用另一种方法吗?