jubba890 Posted March 9, 2015 Share Posted March 9, 2015 Hi! I have 2 tables servers: ID | IP | NAME | TYPE | STATUS serversgroups: ID | NAME | TYPE servergroupsdata: GROUPID | SERVERID On the page I have 2 listbox's and on the left is available ones, and on the right is the ones in the group, I need the ones on the 'available' ones to NOT show if they are in another group OR if they are in the current group you are editing AND they have to be the same type. Example: TestServer: - ID: 1 - TYPE: webserver OtherServer: - ID: 2 - TYPE: randomserver FinalServer: - ID: 3 - TYPE: webserver ################ TestGroup: - ID: 1 - TYPE: webserver TestGroup: - ID: 1 - TYPE: webserver ################ Row1: - GROUPID: 1 - SERVERID: 1 ROW2: - GROUPID: 2 - SERVERID: 3 Expected in 'available' for groupID 1: ##NOTHING## Expected in 'in the group' for groupID 1: - TestServer [With ID of 1] Is this a confusing way to do a simple task? Anything will help, I tried to fetch the array and then dowhile($var = mysqli_fetch_Array($query) but I ended up with 3 of those and a bunch of IF statements and I'm just really irritated right now. ANY help is MUCH appreciated Quote Link to comment Share on other sites More sharing options...
Barand Posted March 9, 2015 Share Posted March 9, 2015 You should be able to construct the desired list using SQL but your spec needs several ambiguities clarifying On the page I have 2 listbox's and on the left is available ones Does ones refer to group or servers? to NOT show if they are in another group OR if they are in the current group you are editing AND they have to be the same type. Mix of AND and OR - is that A OR (B AND C) (A OR B) AND C TestGroup: - ID: 1 - TYPE: webserver TestGroup: - ID: 1 - TYPE: webserver Both have same ID value AND they have to be the same type. Your server and group entities both have type attributes. To which does type refer? I need the ones on the 'available' ones to NOT show if they are in another group another group in respect to what? Is there pre-selection of a group to process? Quote Link to comment Share on other sites More sharing options...
jubba890 Posted March 15, 2015 Author Share Posted March 15, 2015 Does ones refer to group or servers? Ones refer to the servers Both have same ID value My bad, the second group is supposed to have the ID of 2 Your server and group entities both have type attributes. To which does type refer? Both, a group with "type" of web cannot have a server whom's "type" is mysql another group in respect to what? Is there pre-selection of a group to process? If there are 2 groups: G1 and G2. and there was 1 server (S1), you would not see S2 on G2's list if it was already in G1 and vise-versa. Mix of AND and OR - is that A OR (B AND C) (A OR B) AND C If server is not in another group AND the server types match (for group and server) AND they are not already in the group. 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.