Nieeru Posted November 3, 2010 Share Posted November 3, 2010 Hey there! Still very new to these forums. I'm creating a script that reads an external XML file, populating a database and then returning results. I know that I can just read the XML file, loop it through foreach with pre-defined variables outside and then preform the checks, like this: $var1 = true; $var2 = true; foreach($xml->info->members as $member) { if(empty($member['classId'] == 1)) { $var1 = false; } elseif(empty($member['classId'] == 2)) { $var2 = false; } } if(!$var1) { // Do something if it's FALSE } else { // Do something if it's TRUE } ... However, I tried using this logic with MySQL, selecting everything in the database as it only stores the information I need, then checking the query, for so to continue parsing it. I tried using if(empty($data['classId'] == 1)) { $var1 = FALSE; } but it just returns an error while if(mysql_num_rows($data['classId'] == 1) < 1) { $var1 = FALSE; } always returns false, even if the field classId is populated by one or more members. Without having to create seperate queries for every occurance of classId (which for the record are 10 different ID's), I don't really know how to solve this issue. Basically, what I want to do is, select everything from a database, define variables for every class ID as true by default, then loop the returned mysql results and if there are no members within one or more classId's define them as false. I'm not really sure how to work out the logic behind it. I'd really appreciate some help with this. Quote Link to comment https://forums.phpfreaks.com/topic/217689-checking-returned-results-in-a-while-loop/ Share on other sites More sharing options...
fenway Posted November 7, 2010 Share Posted November 7, 2010 I don't see a query anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/217689-checking-returned-results-in-a-while-loop/#findComment-1131382 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.