List job openings

In this tutorial section you will create the page that displays a list of available jobs. This page is accessible from the user's main page, through the View job ads link. This link leads to the user/view_jobs page.

To build the job listing page, follow the next steps:

  1. First open the user/view_jobs page in Dreamweaver.
  2. To retrieve the jobs from the database table, you will have to create a recordset. When creating it, you must take into consideration that each job in the database has a deadline, which is stored in the table as a date field. In order to avoid applications for expired jobs, the recordset will have to filter out any entry that has the deadline inferior to the current date.
  3. To access the new recordset dialog box, click on the Plus (+) button of the Bindings tab. If the Bindings tab is not visible, open it from Window -> Bindings.

  4. In the pop-up menu that appears, select Recordset (Query). The new recordset interface will open in its basic form.

  5. Enter a name for the recordset in the first text-box (e.g. rsJobs).

  6. In the Connection drop-down menu, select the database connection that you are using for this site.

  7. In the Table drop-down menu, select the job_job table as it contains the jobs posted by companies. At this point, your recordset retrieves all jobs in the database, regardless of their state.

  8. Switch to advanced view, as you need to extend the recordset, so that instead of foreign key values to display the correct labels, and to eliminate the expired jobs. To create the advanced recordset in an easy manner, you can simply copy and paste the following code in the SQL text area:

    SELECT * FROM job_job, domain_dom, location_loc
    WHERE job_job.iddom_job = domain_dom.id_dom
    AND job_job.idloc_job = location_loc.id_loc
    AND job_job.deadline_job >= NOW()

     

  9. The first two conditions in the WHERE clause are used for the JOIN operation, while the last is used to eliminate expired entries. The deadline set for each job cannot be lower than the current date. The function that returns the current date for most database software is NOW().


     

  10. Click OK when done.

 

Once you have all non-expired jobs in the recordset, you must add some elements that will display them in the page. The easiest way to do it is with a dynamic table:

  1. The Dynamic Table command can be accessed from the Application tab of the Insert panel. Once you've clicked its corresponding button, a dialog box will open. Configure it to display all records in the rsJobs recordset, and then click the OK button to add it to the page:


     

  2. Now you have the HTML table in the page, listing all available jobs. In the table however, there are too many unnecessary details, as the dynamic table retrieves all columns. Keep only the title_job, type_job, name_dom and name_loc columns and delete the rest.

  3. Rename the titles of the columns you've kept to something more understandable, like Title, Type, Domain and Location. Also, select the entire first row, and from the Property Inspector check the Header option:


     

  4. To allow users see more details about the job and even apply for a position, you will have to add a new column, storing a link to the job_detail page. Right-click in the Location cell and, from the pop-up menu, select the Table -> Insert Rows or Columns option. Add a new column, after the current selection.

  5. Now that you have a spot to place the link, it's time to actually create it. In the first row's last cell type Details, as the column header. In the second row's last cell enter "See more details". Select this text and click on the Browse for File button next to the Link drop-down menu in the Property Inspector.

  6. Browse to the user folder and select the job_detail page. Click on the Parameters button to pass it the job identifier. In the dialog box that opens, enter for name id_job, and for the value select the id_job dynamic data (by pressing the lightning icon, and choosing the appropriate field from the rsJobs recordset). Click on OK to close the user interfaces:
    Note:
    For ASP users, the parameter value should be: <%=(rsJobs.Fields.Item("id_job").Value)%>


     

  7. Now you can save and view your page in the browser, by pressing the F12 key. Aside each valid job, a link that will open the job details page is displayed, pointing to the same page, but with different parameters:


     

  8. To make sure the dynamic table header and the See more details link do not appear when there are no jobs in the database, select the entire dynamic table and apply the Show If Recordset Is Not Empty server behavior. This is a server behavior that comes with Macromedia Dreamweaver and can be accessed from the Server Behaviors tab -> + -> Show Region. Simply configure it to check the rsJobs recordset and click the OK button.

In the next topic of the tutorial you will create the job detail page, where users can check out all other details concerning the job and also apply for a position.