nade93 Posted December 2, 2010 Share Posted December 2, 2010 Hi All i hope someone can help about to scream! basically I am trying to do a few things with the statement below; First i want to check if the user id exists in member_categories_position. If it Does i want then to exclude all entries from the second statement where member_id equals all results from the first statement the third statement is the else statement that displays if the member_id is not present in the member_categories position. PROBLEM - the result from the first system loops fine, however when i try and insert into the second statement (!='$memid') is produces no results and has no effect. I think the problem is that $memid is a looped result. How do i get the second statement to say that any member_id that is in member_categories_position will not show in that statement? $sql2 = "SELECT * FROM member_categories_position a JOIN member_users b ON b.id = a.member_id"; $rs2 = mysql_query($sql2); while ($row = mysql_fetch_array($rs2)){ $memid = "".$row['member_id'].""; } if(mysql_num_rows($rs2) != 0){ $new= "SELECT * FROM member_categories JOIN member_users on member_categories.member_id=member_users.id JOIN member_config on member_categories.member_id=member_config.member_id WHERE member_categories.categories='$category' and member_categories.member_id !='$field' group by member_config.member_id order by RAND() limit 0,42"; $rs = mysql_query($new); while ($row = mysql_fetch_assoc($rs)) { echo "result excluding member ids from the first statement"; } echo "<div class=\"clear\"></div>"; } else{ $new= "SELECT * FROM member_categories JOIN member_users on member_categories.member_id=member_users.id JOIN member_config on member_categories.member_id=member_config.member_id WHERE member_categories.categories='$category' group by member_config.member_id order by RAND() limit 0,42"; $rs = mysql_query($new); while ($row = mysql_fetch_assoc($rs)) { echo "Result with all member ids"; } echo "<div class=\"clear\"></div>"; }} Quote Link to comment https://forums.phpfreaks.com/topic/220477-stuck-in-a-world-of-loops/ Share on other sites More sharing options...
nade93 Posted December 2, 2010 Author Share Posted December 2, 2010 hmm still struggling with this after three hours! where am i going wrong??? any help would be amazing please Quote Link to comment https://forums.phpfreaks.com/topic/220477-stuck-in-a-world-of-loops/#findComment-1142365 Share on other sites More sharing options...
kenrbnsn Posted December 2, 2010 Share Posted December 2, 2010 Please explain what this code is supposed to be doing. Ken Quote Link to comment https://forums.phpfreaks.com/topic/220477-stuck-in-a-world-of-loops/#findComment-1142370 Share on other sites More sharing options...
nade93 Posted December 2, 2010 Author Share Posted December 2, 2010 Please explain what this code is supposed to be doing. Ken hi ken its all in the text really basically there is a directory listing with 6 preferential listings running off a different script that are sorted into the members_categories_position table. However I do not want the listing to be duplicated, so need to check if the member user exists in the members_categories_position table, if it does it needs to exclude them from the listings Quote Link to comment https://forums.phpfreaks.com/topic/220477-stuck-in-a-world-of-loops/#findComment-1142389 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.