我很难解决这个问题:需要帮助。
这是我的原始代码:
function.php
public function getTestScriptSummary($projectID){
$sql = "SELECT * FROM tbl_test_script_header WHERE fld_projectID='$projectID'";
$query = $this->DBH->prepare($sql);
$query->execute();
while($row = $query->fetch(PDO::FETCH_ASSOC)){
$testResults .= "
<tr>
<td style=\"padding:3px;\">".$row['fld_dateEnded']."</td>
<td style=\"padding:3px;\">".$row['fld_testerName']."</td>
<td style=\"padding:3px;\">".$row['fld_scriptID']."</td>
<td style=\"padding:3px;\">".$row['fld_testPhase']."</td>
<td style=\"padding:3px;\">".$row['fld_status']."</td>
</tr>";
}
return $testResults;
}
view.php
echo $User->getTestScriptSummary($_POST['projectName']);
使用此代码,我得到了正确的答案。但是我不想在我的函数中显示表格(我的意思是testResults中的值)。相反,我希望它显示在view.php中。我该怎么做?
答案 0 :(得分:2)
试试这个。这会将结果合并为单个数组。
$testResults =array();
while($row = $query->fetch(PDO::FETCH_ASSOC)){
$testResults[] = $row;
}
return $testResults;