我想知道是否有人可以帮助我解决这个问题。 我想在同一页上多次打印/回显函数的解决方案。这可能吗?
这是我的功能:
public function getFeedback($p_iUserid) {
include("Connection.php"); //open db
try
{
$sql = "select DiaryOpmerkingen, DiaryDoctorcomment from tblDiary
WHERE fk_UserId = ".$p_iUserid."
AND DiaryDay = '".$this->Day."';";
$rResult = mysqli_query($link, $sql);
return $rResult;
}
catch(Exception $e)
{
// no connection database
$feedback = $e->getMessage();
}
mysqli_close($link);
}
这就是我现在设法调用该函数的方式。但它只工作一次:
if(mysqli_num_rows($feedbackPatient) > 0)
{
while($oUser = mysqli_fetch_assoc($allUsers))
{
echo $oUser['DiaryOpmerkingen'];
}
}
希望有人能帮忙! 无论如何谢谢。
最佳答案
为您的打印任务创建一个函数,然后根据需要多次调用它:
function print_the_stuff($feedbackPatient){
if(mysqli_num_rows($feedbackPatient) > 0)
{
while($oUser = mysqli_fetch_assoc($allUsers))
{
echo $oUser['DiaryOpmerkingen'];
}
}
}
然后,在任何需要打印的地方:
print_the_stuff($feedbackPatient);
关于php - 如何在一页中多次回显一个数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6081331/