prepare("SELECT * FROM material_donations WHERE user_id = ?"); $stmt->bind_param("i", $user_id); $stmt->execute(); $result = $stmt->get_result(); $donations = $result->fetch_all(MYSQLI_ASSOC); } elseif ($role === 'recipient') { // Fetch donations available for the recipient (donations by other users) $stmt = $conn->prepare("SELECT * FROM material_donations WHERE user_id != ?"); $stmt->bind_param("i", $user_id); $stmt->execute(); $result = $stmt->get_result(); $donations = $result->fetch_all(MYSQLI_ASSOC); } else { // If the user is neither donor nor recipient (should not happen) echo "Invalid role."; exit; } ?>
Item Name | Condition | Quantity | Notes |
---|---|---|---|