Jump to content

Loop question


karimali831

Recommended Posts

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/203900-loop-question/
Share on other sites

$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');

Link to comment
https://forums.phpfreaks.com/topic/203900-loop-question/#findComment-1067940
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.