I have a many to many table called eng_job_cat which contains 2 fields. One field holds an engineer number while the other holds the specific job categories that the engineer has been assigned to. A quick example:
eng_no | job_cat_no
1-------------7
1-------------4
1-------------32
1-------------17
2-------------7
2-------------4
2-------------39
2-------------16
I'm in the process of altering a script to delete engineers. I want to warn the users if the engineer that they are trying to delete is the only one assigned to a particular job category. I had been doing it by deleting the engineer and his eng_no from the table above and then running a mysql_num_rows and although it worked, it didn't warn the user before deleting the Job Categories.
So, this is where I'm up to so far:
$eng_no_query = "SELECT eng_no FROM engineers";
$eng_no_result = mysql_query($eng_no_query);
while($row = mysql_fetch_array($eng_no_result))
{
//Select the job category number from the eng_job_cat table where the engineer number = $row['eng_no']//
$eng_no_assigment_query = "SELECT job_cat_no FROM eng_job_cat WHERE eng_no='" . $row['eng_no'] . "'";
$eng_no_assigment_result = mysql_query($eng_no_assigment_query );
}
$eng_no_assigment_result now contains all of the job category numbers of the job categories assigned to that engineer. What I want to do now is to check if there are other engineers assigned to the job categories I have just pulled back. if not, I want to list the ones in $eng_no_assigment_result.
I'm half way there I think but I've kinda run into a wall now....