I have two tables - employment and duties. The employment table holds information like company, position, dates, etc. and the duties table holds the duties for the job the person just entered. Both tables have rid (resume id) and jid (job seeker id).
When a job seeker submits information from the employment form it's entered into the employment table and the employment_id (primary key, auto-increment) is captured via mysql_insert_id. The resulting page is a form with a single field named duty, which when submitted is entered into the duties table along with the employment_id. Once processed they have the option of adding another duty or moving on to another section of the resume.
I did it this way instead of simply adding a few duty fields named duty1, duty2, etc. on the employment form because I didn't want an excessive number of unused fields in the employment table or not enough in case the person had more duties to list than I had fields.
I thought about using a text area on the employment form, but I want to display the duties as a bullet list and you can't do this with a textarea unless you use an HTML editor, which I don't want to do. Even with an HTML editor there is no guarantee that everyone would use the bullet option on the editor. So the only way is to enter the duties individually.
My problem is querying the database to list all of that person's employment history with the duties listed in bullet form for each separate employment experience. For example:
Company A - Dallas, TX
Store Manager, Sep 2008 - Present
Hiring and training store personnel.
Ensuring sales goals are met.
Ensuring customer satisfaction.
Company B - Tucson, AZ
Asst. Store Manager, Jan 2006 - Sep 2008
Assisted store manager in hiring and training store personnel.
Assisted store manager in ensuring sales goals were met.
Assisted store manager in ensuring customer satisfaction.
One person may enter several jobs each one being assigned a unique employment_id number, and they may enter several duties for each job (employment_id number).
I've tried using several different query joins but I only get one result returned. Below is what I use to query just the employment table. The question I have is how do I also query the duties table to list the duties for each job and display them in a bullet list as in the examples above?
$rid = '1'; // resume id
$jid = '1'; // jobseeker id
$query = "SELECT * FROM employment WHERE jid='$jid' AND rid='$rid'";
$result = mysql_query ($query);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$employment_id = stripslashes($row['employment_id']);
$company = stripslashes($row['company']);
$location = stripslashes($row['location']);
$position = stripslashes($row['position']);
$dates = stripslashes($row['dates']);
echo "<p>$company - $location<br />$position, $dates</p><ul>";
$query = "SELECT duty FROM duties WHERE employment_id='$employment_id' AND rid='$rid' and jid='$jid'";
$result = mysql_query ($query);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$duty = stripslashes($row['duty']);
echo "<li>$duty</li>";
}
echo "</ul>";
}
Thanks
David P