Jump to content

stuck in a world of loops!


nade93

Recommended Posts

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>";

}}

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.