所以我试图创建多个"结果"数组,并在"主"数组中填充我的语句结果.
但是,似乎每次循环通过时结果数组都会被覆盖,而不是创建一个额外的数组.
我的代码:
function retrieve_clients() {
$coach_id = $_SESSION['user_details']['id'];
$connection = connection();
$statement = select($connection, '*', 'relations', 'coach_id', '=');
$statement->bind_param('i', $coach_id);
if ($statement->execute()) {
$statement->bind_result($id, $coach_id, $client_id, $relation_date);
while ($statement->fetch()) {
$_SESSION['clients'] = array(
array($id, $coach_id, $client_id, $relation_date)
);
}
}
$statement->close();
}
Run Code Online (Sandbox Code Playgroud)
我再也想不出来了.请不要理我,因为我还是编程新手.