1 回答

TA貢獻1878條經驗 獲得超4個贊
在獲取SQL數據的函數中,第一次循環后返回結果:
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
}
}
}
從數據庫檢索每個結果后,您需要將其添加到某種$all_results變量中。循環完成后,返回$all_results。
- 1 回答
- 0 關注
- 112 瀏覽
添加回答
舉報