Department: $department"; ### Look for jobs in each department and print as list ### $query2 = "SELECT jcode, designation from listing WHERE listing.fk_department = '$id'"; $result2 = mysql_db_query($database, $query2, $connection) or die ("Error in query: $query2. " . mysql_error()); echo "

"; echo "

"; } } ####################### # Echoing job details # ####################### if($cmd == "Details"){ if (!$jcode || $jcode == "") { header("Location:?cmd=Error"); exit; } ### Get job details ### $query = "SELECT listing.designation, listing.jcode, department.department, location.location, salary.salary, listing.responsibilities, listing.qualifications, listing.cname, listing.cmail, listing.posted from department, listing, location, salary WHERE department.id = listing.fk_department AND location.id = listing.fk_location AND salary.id = listing.fk_salary AND listing.jcode = '$jcode'"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); ### Checking for errors ### if (mysql_num_rows($result) <= 0) { header("Location:?cmd=Error"); exit; } else { ### Obtain data from query ### list($designation, $jcode, $department, $location, $salary, $description, $qualification, $cname, $cmail, $posted) = mysql_fetch_row($result); echo " Designation: $designation

Department: $department

Location: $location

Salary: $salary

Responsibilities: $description

Qualifications: $qualification

Contact: $cname

Job code: $jcode

Posted on: "; echo fixDate($posted); echo "

Apply online for this job, or return to job listings"; } } ###################### # Applying for a job # ###################### if($cmd == "Apply"){ if (!$jcode || $jcode == ""){ header("Location:?cmd=Error"); exit; } ### Get job details ### $query = "SELECT designation, jcode, department from listing, department WHERE jcode = '$jcode' AND department.id = listing.fk_department"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); ### Checking for errors ### if (mysql_num_rows($result) <= 0){ header("Location:?cmd=Error"); exit; } else { ### Obtain data from query ### list($designation, $jcode, $department) = mysql_fetch_row($result); ### Clean up ### mysql_free_result($result); ?> Please fill up this form to apply for the post of
First name* Last name*
Address line 1*
Address line 2
City* State* Zip*
Country*
Phone*
(example: 703-555-5555)
E-mail address*
(example: mykel@domain.com)
Web site URL
(example: http://www.somedomain.com)
Date of birth*
(in dd-mm-yyyy format)
- -
You may fill all or none of the rows below; ensure that no fields are left empty per filled-in row
Institute/University
(example: XYZ University)
Degree
(example: Master's degree)
Primary subject
(example: Accounting)
Year
(example: 1992)
You may fill all or none of the sections below; ensure that no fields are left empty per filled-in section
Employer [] (example: ABC, Inc.)"; } ?> Industry (example: Advertising)"; } ?> Start year (example: 1996)"; } ?> End year (example: 1998)"; } ?>
Responsibilities (example: Managing projects and...)"; } ?>
You may fill all or none of the rows below; ensure that no fields are left empty per filled-in row
Skill
(example: PHP)
Experience
(example: 2 years)
year(s)
You may fill all or none of the rows below; ensure that no fields are left empty per filled-in row
Name
(example: Mykel Nahorniak)
Phone
(example: 703-555-5555)
Email address
(example: mykel@domain.com)
I am willing to relocate if necessary
0){ $errorList[$count] = "Duplicate entry: An application for this job already exists with the same email address"; $count++; } } ### Validate multiple-record items ### ### 1. get number of entries possible (rows) ### ### 2. check to see if any text field in that row is filled up ### ### 3. if yes, ensure that all other fields in that row are also filled ### ### 4. if no, go to next row and repeat ### ### Check education rows ### for ($x=0; $xReturn to job listings"; } else { ### Or list errors ### listErrors(); } } } /////////////////////// ####################### # Administration Code # ####################### /////////////////////// /* Do not alter the following code unless you are a proficient PHP coder. Altering the code incorrectly may result in corrupting the entire script. */ ##################### # Job Listing Admin # ##################### if($cmd == "Admin"){ ### Get list of departments with open jobs ### $query = "SELECT DISTINCT id, department from department, listing WHERE department.id = listing.fk_department"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); ### Generate a table ### echo ""; ### Echoing from query ### while(list($id, $department) = mysql_fetch_row($result)) { ### Print department name ### echo ""; ### Look for jobs within the department and print as list, add edit and delete links ### $query2 = "SELECT jcode, designation from listing WHERE listing.fk_department = '$id'"; $result2 = mysql_db_query($database, $query2, $connection) or die ("Error in query: $query2. " . mysql_error()); while(list($jcode, $dsg) = mysql_fetch_row($result2)){ echo " "; } } echo "
Department: $department
  $dsg ($jcode) edit delete

Add a new listing or search the database"; } #################### # Adding a listing # #################### if($cmd == "Add"){ ### If form has not been submitted ### if (!$submit) { ?>
Job code*
Designation*   Department*
 
Location*   Salary*
 
Responsibilities*   Qualifications*
 
Contact person*   Email address*
 
Add another entry, or return to job listings"; } else { listErrors(); } } } ##################### # Editing a listing # ##################### if($cmd == "Edit"){ ### Checking for errors ### if (!$jcode || $jcode == ""){ header("Location:?cmd=Error"); exit; } ### Form not yet submitted ### if (!$submit){ ### Get job details ### $query = "SELECT designation, jcode, fk_department, fk_location, fk_salary, responsibilities, qualifications, cname, cmail from listing WHERE jcode = '$jcode'"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); ### Checking for errors ### if (mysql_num_rows($result) <= 0){ header("Location:?cmd=Error"); exit; } else { ### Obtain data from query ### list($designation, $jcode, $department, $location, $salary, $description, $qualification, $cname, $cmail, $posted) = mysql_fetch_row($result); ### Clean up ### mysql_free_result($result); ### Display form with values pre-filled ### ?>
Designation*   Department*
 
Location*   Salary*
 
Responsibilities*   Qualifications*
 
Contact person*   Email address*
 
Edit another entry, or return to job listings"; } else{ listErrors(); } } } ###################### # Deleting a listing # ###################### if($cmd == "Delete"){ if (!$jcode || $jcode == ""){ header("Location:?cmd=Error"); exit; } ### Delete record ### $query = "DELETE FROM listing WHERE jcode = '$jcode'"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); mysql_close($connection); ### Redirect ### echo "Entry successfully deleted.

Go back to Admin, or return to job listings"; } ########################### # Searching for a listing # ########################### if($cmd == "Search"){ if(!$submit) { ?>

Display all applications for the post

"; ?> Your search returned match(es)