Jump to content

Recommended Posts

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 do
while($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 :)

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?

 

 

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.

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.