#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    9
    Rep Power
    0
    I'm developing a database that holds information about crew members. There are 7 categories of service types. Crew members can be associated with any number of categories.

    I'm working on an update form to add or delete categories for a crew member. I first issued a query to find the member's categories. I issued a second query to list all possible categories. I want to show a checkbox for any possible categories that aren't in the member's individual category list. If the member is in categories 1 and 2, but not in 3 or 4, I want to show a checkbox for categories 3 and 4.

    I can get the two category lists to print, but I can't figure out how to compare them.

    Here is the code I have for the select statements:

    Generates the list of member categories:
    $cat_query = "SELECT crew_category.crew_id, crew_category.category_id, category.category_desc
    FROM crew_category, category
    WHERE crew_category.crew_id = "$crew_id" and crew_category.category_id = category.category_id";

    $cat_result = mysql_query($cat_query);


    Generates the list of all possible categories:
    $all_cat_query = "SELECT category_id
    FROM category";

    $all_cat_result = mysql_query($all_cat_query);


    I'm just developing my programming skills (as I'm sure you can tell), so I apologize for my ignorance! Thanks in advance to anyone who can help!
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    << I want to show a checkbox for any possible categories that aren't in the member's individual category list. If the member is in categories 1 and 2, but not in 3 or 4, I want to show a checkbox for categories 3 and 4.
    >>

    Actually i am not clear your rquestion.


    <<
    crew_category.category_id = category.category_id";
    >>

    you have already comparing the id's of both the tables.I don't understand why you are doing a matching again.



    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

    [This message has been edited by Shiju Rajan (edited June 29, 2000).]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    9
    Rep Power
    0
    The purpose of the form is to edit the crew member's category information. The category table holds only the category_id and the category title. The crew_category table is a link table that holds the crew_id and the category_id (So we can add categories later).

    The form displays the current categories for that crew member. If a member has entries in the crew_category table for categories 1 and 2, these will display. I want to allow the user to select categories to add for this member only for categories that don't exist for that member.

    As an example, a member has the following entries in the crew_category table:
    crew_id = 10, category_id = 1
    crew_id = 10, category_id = 2

    I want the update form to display checkboxes for categories 3,4,5, etc., but NOT for categoris 1 or 2, so categories 3,4,5 can be added.

    I'm trying to compare the results of the crew_category lookup with the categories table to see what categories don't exist for this person.

    Sorry about the confusion. I know what results I want, I just don't know how to go about it (or how to explain it)!

    Thanks!

Similar Threads

  1. C++ programming help.
    By Programming1 in forum C Programming
    Replies: 1
    Last Post: January 20th, 2004, 11:47 AM
  2. Array manipulation and removal of array values
    By timwi in forum Perl Programming
    Replies: 10
    Last Post: January 14th, 2004, 11:49 AM
  3. Zip code validation
    By krwyth in forum MySQL Help
    Replies: 2
    Last Post: January 5th, 2004, 02:29 PM
  4. help function to check array for values.
    By Germanjulian in forum PHP Development
    Replies: 1
    Last Post: January 5th, 2004, 10:35 AM
  5. splitting an array by matching values
    By urge in forum PHP Development
    Replies: 0
    Last Post: December 19th, 2003, 02:06 AM

IMN logo majestic logo threadwatch logo seochat tools logo