I am able to successfully iterate through said MySQLi object in a foreach loop like so:
// Retrieving accounts
$stmt = $conn->prepare("SELECT * FROM accounts");
$stmt->execute();
$accounts = $stmt->get_result();
// Iterating over object
foreach ($accounts as $account) {
print_r($account);
}
...hence, I thought this would work, too:
print_r($accounts[0]);
...but it doesn't, as I receive this error message:
Fatal error: Uncaught Error: Cannot use object of type mysqli_result as array
Does anyone know how I would correctly index a MySQLi object similar to what I'm trying, if possible?