karimali831 Posted June 4, 2010 Share Posted June 4, 2010 Hi, Got a prob. $getteams=safe_query("SELECT clanID, userID FROM ".PREFIX."cup_clan_members WHERE userID='$userID'"); while($te=mysql_fetch_array($getteams)) { I echo clanID in $getteams query above: echo '<br>clanID = '.$te['clanID'].''; Output: clanID = 11 clanID = 35 clanID = 37 = is correct. Now I want to use $te['clanID'] in $registered query below: $registered=safe_query("SELECT * FROM ".PREFIX."cup_clans WHERE clanID='".$te['clanID']."' && 1on1='0' && cupID='$cupID'"); if(!mysql_num_rows($registered)) { echo 'no rows'; }else{ echo 'is rows'; } Output: clanID = 11no rows clanID = 35is rows clanID = 37no rows == is correct Problem: If I used if(!mysql_num_rows($registered)) { die('die'); } it will die but there is rows for clanID 35? (above) Don't know much about how loops work but if I changed the query from clanID='".$te['clanID']."' to clanID='35' it'll work fine. So I don't want it to die if there is rows for any clanID in the loop if that makes sense? From the looks of it, it will die if a single clanID has no rows. Hope you understand and thanks for help. Quote Link to comment Share on other sites More sharing options...
dabaR Posted June 4, 2010 Share Posted June 4, 2010 foreach ($team_ids as $team_id) { $registered = ...; if (mysql_num_rows($registered)) $is_registered_on_at_least_one_team = true; } if (empty($is_registered_on_at_least_one_team)) die('a horrible death'); //jk Quote Link to comment Share on other sites More sharing options...
karimali831 Posted June 4, 2010 Author Share Posted June 4, 2010 Sorry don't totally understand, I'm PHP beginner Quote Link to comment Share on other sites More sharing options...
dabaR Posted June 4, 2010 Share Posted June 4, 2010 $getteams=safe_query("SELECT clanID, userID FROM ".PREFIX."cup_clan_members WHERE userID='$userID'"); while($te=mysql_fetch_array($getteams)) { $registered=safe_query("SELECT * FROM ".PREFIX."cup_clans WHERE clanID='".$te['clanID']."' && 1on1='0' && cupID='$cupID'"); if (mysql_num_rows($registered)) $is_registered_on_at_least_one_team = true; } if (empty($is_registered_on_at_least_one_team)) die('error message'); Quote Link to comment 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.