I have created a jobtracking database for internal use but now would like to add a client login where the client can only see information about their own jobs. I can't seem to wrap my head around this. I can't get my database to select the proper information.
Basically I have a table with contact information (along with username, password) and a table with information about the particular job (what it is, where it is in development stages, etc). I don't understand how to get the user to login in and then see JUST their information.
SELECT *
FROM job, contact
WHERE ?????
Thanks,
Kyle
php help
Moderator: General Moderators
You are not going to get very far without some relation between the contact table and the job table...
When you say you want the user to only see their own information, do you mean that you want them to see the jobs they are interested in, or the jobs they have inserted into the system?
If the former, you are going to need some kind of "Mark this job as a favourite" functionality, which writes the user_id and the job_id to a separate table. Then, when you come to show the user their "favourites", you just pull everything out of this favourites table where the user_id equals the current user.
If the latter, then I'm assuming that one of the fields in the jobs table is an "author" field, in which case, you pull everything out of the jobs table where the author equals the current user. (If this table is large, you should consider indexing the author column).
Either way, as I said first of all, you need some link between the user and the jobs they need to see.
When you say you want the user to only see their own information, do you mean that you want them to see the jobs they are interested in, or the jobs they have inserted into the system?
If the former, you are going to need some kind of "Mark this job as a favourite" functionality, which writes the user_id and the job_id to a separate table. Then, when you come to show the user their "favourites", you just pull everything out of this favourites table where the user_id equals the current user.
If the latter, then I'm assuming that one of the fields in the jobs table is an "author" field, in which case, you pull everything out of the jobs table where the author equals the current user. (If this table is large, you should consider indexing the author column).
Either way, as I said first of all, you need some link between the user and the jobs they need to see.
-
kyledonmoyer
- Forum Newbie
- Posts: 4
- Joined: Tue Sep 12, 2006 11:34 am
They ARE related...I have them attached with id's .....if a job_id has the number of a contact_id (and a contact_id CAN have multiple jobs attached to it), they get linked. I have that working already. I just can't seem to get the users login to show JUST the information that is attached to THEIR contact_id.
OK - then this should do it:
where $contact_id is a php variable that you assign when the user logs in.
Code: Select all
SELECT *
FROM job
WHERE contact_id = '$contact_id'
-
kyledonmoyer
- Forum Newbie
- Posts: 4
- Joined: Tue Sep 12, 2006 11:34 am
-
kyledonmoyer
- Forum Newbie
- Posts: 4
- Joined: Tue Sep 12, 2006 11:34 am