I am trying to make a while()
loop, where I get some data from the database, and then I need to make another loop which is based on one of the variables given by the last while()
loop.
There are no typo's as far I can see, but I keep getting
Fatal error: Call to a member function bind_param() on boolean in ... on line 77."
This is the code: (IMAGE FOR BETTER STRUCTURE: https://i.stack.imgur.com/wooxX.jpg)
<?php
$sql = 'SELECT raised_id, user_id, project_id, amount FROM cf_donations ORDER BY raised_id DESC LIMIT 6';
$stmt = $connection->prepare($sql);
$stmt->bind_result($rid, $uid, $pid, $amount);
$stmt->execute();
while($stmt->fetch()){ ?>
<?php
$userinfoquery = 'SELECT first_name, last_name, profile_image FROM cf_users WHERE user_id = ?';
$stamt = $connection->prepare($userinfoquery);
$stamt->bind_param('i', $uid);
$stamt->bind_result($firstname, $lastname, $image);
$stamt->execute();
while($stamt->fetch()){ ?>
<div class="donationDiv">
<p><?= $amount ?>$</p>
</div>
<?php } ?>
<?php } ?>
Any help is highly appreciated!