php/sql question.....sorting data in tables

Discussion in 'OT Technology' started by Mirlyn, Feb 16, 2004.

  1. Mirlyn

    Mirlyn Guest

    I've got a table that is four columns wide by many rows deep. Each column will have the results of a query of a particular table in a database.

    Machine - Users - CPU - Uptime

    Where machine is the name of the machine being monitored, the other columns will display any available data from that machine name (gathered from separate tables in the db).

    Whats the best way to go about doing this? Can you sort/match objects in an array in php based on a key-search? In other words, could I sort the Users column in the table to correspond with the appropriate machine entry? What if there is no machine entry for that column...will it skip over it or shift all the cells up?

    Aside from creating a loop to query the database for every machine name (100+ machines...thus creating a large load), is there another way? Suggestions?

    Thanks.
     
  2. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    WHy not create a query that presents the info in the format you've layed out? All of the information relates to each so I don't see why you can't just create one master query that is based off of the other queries
     
  3. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    :werd: That would be the easiest way.
     
  4. Mirlyn

    Mirlyn Guest

    The problem that I see is that not every machine is listed in every table. So machine alpha may have records for CPU, users, and uptime, whereas machine beta is only monitored for CPU and uptime and machine gamma is monitored on users and CPU. Sometimes machines are only monitored by one or two things, instead of all three.

    I've only done some basic sql stuff, can you query multiple tables and still make things line up when things are missing in the result?
     
  5. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    That's fine, if there's no information provided you can either supress the machine, or simply put blanks in the other columns. It's up to you.
     
  6. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    or he could use Boyce-Codd Normalization to prevent spaces in the rows.
     
  7. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    How long have you been waiting to use that ;) :rofl:
     
  8. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    since Fall Semester 2002 when i learnt it :big grin:

    and to tell you the truth i can normalize worth SHIT!
     
  9. jayrod

    jayrod Lurker extraordinaire...

    Joined:
    Jul 19, 2001
    Messages:
    2,663
    Likes Received:
    0

    :rofl:

    I just learned that yesterday
     

Share This Page