I'm having issues implementing an SQL query using PDO.
$friend_emails = $pdo->prepare("SELECT DISTINCT User2
FROM members
WHERE User1 = '$user'
UNION
SELECT DISTINCT User1
FROM members
WHERE User2 = '$user'");
$friend_emails->execute();
for($i=0; $row = $friend_emails->fetch(); $i++) {
echo "foo";
}
"foo" doesn't show at all. I var_dumped $row and $friend_emails->fetch() both of which are a
boolean false
so I'm not exactly sure why that is, I thought it would return an array of the data.
Any help is greatly appreciated!