I'm trying to return all records from my database where the userID is equal to the logged in user.
I have the following only for some reason its not returning anything, can anybody see any obvious errors?
<?php
$interestsquery = "SELECT *
FROM user_interests
WHERE user_id = $usersClass->userID()";
$result = mysql_query($interestsquery);
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "{$row['interest']}";
}
?>
Unfortunately, you can't call functions and have them parsed that way. You'll either need to concatenate manually, or set a variable and parse that.
Try this:
"SELECT * FROM user_interests WHERE user_id = " . $usersClass->userID();
Or this:
$uid = $usersClass->userID();
"SELECT * FROM user_interests WHERE user_id = $uid";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With