gpt4 book ai didi

php - 如何在一页中多次回显一个数组?

转载 作者:可可西里 更新时间:2023-10-31 23:34:27 25 4
gpt4 key购买 nike

我想知道是否有人可以帮助我解决这个问题。我想在同一页上多次打印/回显函数的解决方案。这可能吗?

这是我的功能:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com