Jump to content

Recommended Posts

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. :)

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.