Extract values from lookup tables and display

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • guoxin
    New Member
    • Feb 2008
    • 2

    Extract values from lookup tables and display

    Hi All,

    I've encountered a problem which i find for answers but to no avail and i hope you all can help. I've got 4 tables namely, User_Login, Admin_Login, Projects and Mapping.

    User_Login
    -user_id (PK) INTEGER NOT NULL AUTO INCREMENT
    -user_username VARCHAR(30) NOT NULL
    -user_password VARCHAR(30) NOT NULL

    Admin_Login
    -admin_username VARCHAR(30) NOT NULL
    -admin_password VARCHAR(30) NOT NULL

    Projects
    -project_id (PK) INTEGER NOT NULL AUTO INCREMENT
    -project_name VARCHAR(30) NOT NULL

    Mapping
    -user_id (FK)
    -project_id (FK)

    Mapping is used as a lookup table when the administrator want to assign projects to the newly created user so we use the user_id from User_Login and project_id form Projects as a reference.

    But here comes the problem, i execute the following command, $sql = "SELECT project_name FROM Projects, Mapping, User_Login WHERE Mapping.user_id =User_Login.use r_id AND Mapping.project _id=Projects.pr oject_id"; so the scenario is when a particular user is logged in, the projects will be displayed in a dropdown list where user can select which project he/she want to submit. But the dropdown list won't show up anything so i'm really asking you all for help. I'll be really grateful Thanks.
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Originally posted by guoxin
    Hi All,

    I've encountered a problem which i find for answers but to no avail and i hope you all can help. I've got 4 tables namely, User_Login, Admin_Login, Projects and Mapping.

    User_Login
    -user_id (PK) INTEGER NOT NULL AUTO INCREMENT
    -user_username VARCHAR(30) NOT NULL
    -user_password VARCHAR(30) NOT NULL

    Admin_Login
    -admin_username VARCHAR(30) NOT NULL
    -admin_password VARCHAR(30) NOT NULL

    Projects
    -project_id (PK) INTEGER NOT NULL AUTO INCREMENT
    -project_name VARCHAR(30) NOT NULL

    Mapping
    -user_id (FK)
    -project_id (FK)

    Mapping is used as a lookup table when the administrator want to assign projects to the newly created user so we use the user_id from User_Login and project_id form Projects as a reference.

    But here comes the problem, i execute the following command, $sql = "SELECT project_name FROM Projects, Mapping, User_Login WHERE Mapping.user_id =User_Login.use r_id AND Mapping.project _id=Projects.pr oject_id"; so the scenario is when a particular user is logged in, the projects will be displayed in a dropdown list where user can select which project he/she want to submit. But the dropdown list won't show up anything so i'm really asking you all for help. I'll be really grateful Thanks.
    Firstly, please check if any projects are assigned to any used who is logging in?

    Comment

    Working...