1 回答

TA貢獻(xiàn)1878條經(jīng)驗 獲得超4個贊
在獲取SQL數(shù)據(jù)的函數(shù)中,第一次循環(huán)后返回結(jié)果:
function show_available_equipment($users_site, $timeStampFrom, $timeStampTo){
// defines db from instialize page as a global variable
foreach ($timeStampFrom as $timeStampStart=>$timeStampTo) { // <----- Only runs once
........................
//if there is a SQL error exit
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: book_gear.php?error=sqlerror123");
exit();
}
// otherwise go ahead
else {
...........................
$result = mysqli_stmt_get_result($stmt);
return $result; // <---------- Returns after first loop
}
}
}
從數(shù)據(jù)庫檢索每個結(jié)果后,您需要將其添加到某種$all_results變量中。循環(huán)完成后,返回$all_results。
- 1 回答
- 0 關(guān)注
- 124 瀏覽
添加回答
舉報