liamloveslearning Posted July 7, 2011 Share Posted July 7, 2011 im trying to call all users from a database with the same interests as the current, logged in user on my website. I have the following // Get Session USER interest $interestsquery = "SELECT `interest` FROM `user_interests` WHERE `user_id` = " . $usersClass->userID(); $result = mysql_query($interestsquery); $interests = array(); while(list($interest) = mysql_fetch_array($result)) $interests[] = $interest; $interest1 = $interests['1']; $interest2 = $interests['2']; $interest3 = $interests['0']; // END INTERESTS //USers with Same Interests $interests_query = "SELECT * FROM produgg_users join user_interests on produgg_users.id = user_interests.user_id where interest = '$interest1' and produgg_users.id != '".$usersClass->userID()."'"; $interests_result = mysql_query($interests_query) or die(mysql_error()); if($interests_result != 0) { while($interests_row = mysql_fetch_array($interests_result, MYSQL_ASSOC)) { echo $interests_row['user_id']; } } else { print "No users to display!"; } //END SAME INTERESTS which doesnt bring back any data, yet if I add (beneath //USers with Same Interests) $interest1 = 'footy'; the interests_query seems to work, can anybody see where im going wrong? Quote Link to comment https://forums.phpfreaks.com/topic/241302-query-not-calling-data-from-table/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.