Display article

In this section of the tutorial you will build the page that actually displays the content of an article. As this page will be included in the main index of the site, you can skip adding links that will change the article, or point towards another page.

The purpose of this page is to retrieve an article from the database, and display its contents on page. The article ID to be retrieved  is passed to the page through an URL parameter, which is fed into a filtered recordset. This way, only the selected article will be displayed.

To create this page, follow the next steps:

  1. Open the front/view_art.php page in Dreamweaver.
  2. Create a new recordset into the page, by clicking on the Plus (+) button of the Bindings tab. From the pop-up menu, select Recordset (Query).
  3. The Basic dialog box opens. Configure it, by selecting the database connection you are using for the site, and in the table drop-down menu, select pages_pag. Now the recordset retrieves all records from the database, regardless of the id_pag parameter that is passed to it.
  4. To filter the recordset, select in the Filter drop-down menu the id_pag table field, and for the condition set it to be equal to an URL parameter called id_pag.
  5. At this point the page displays only the recordset that is required through the parameter, and you can finish configuring the recordset. Just click on the Ok button to add it into the page. Also, don't forget to enter a name for your recordset: rsArticles:

  6. Now the rsArticles recordset appears in the Bindings tab. Since all this page will do is display the content of the retrieved article, you can simply drag & drop the body_pag field from the Bindings tab, onto the page:

  7. At this point, the page to display the content of an article is finished, and you can save it and upload it to the server. There is no point in previewing it yet, unless you know the exact URL parameter for an existing article.

 

When loaded in the browser with a correct id_pag value, it will display similar to the image below:

 

 

The next step is to integrate the three pages you've created until now (the menu, article lists and article page) into a single file, with the help of MX Includes.