Create page to display current order

In this last section dedicated to building the application front-end you will create a page that lists the order details for the currently opened order. The page will use a filtered recordset and a dynamic table to display all products in the current order.

To create this page, follow the steps below:

  1. Open the view_order page in Dreamweaver.

  2. Add a new recordset by clicking on the Plus (+) button of the Bindings tab. Then click on the QuB3 button to open the MX Query Builder user interface. MX Query Builder is a tool that allows creating queries in a visual manner, using only simple operations. For more information regarding MX Query Builder, consult its user manual.

  3. In the user interface that opened select the database connection defined at the beginning and enter a name for the recordset.


     

  4. After you have defined the recordset name and database connection, click the New Query button. Enter its name in the dialog box that loads and click OK. The main MX Query Builder user interface will load next. The user interface displays the tables in the left bottom side, and the SQL query, results and columns in the center - bottom part of the screen.

  5. To select the tables to use simply check their checkboxes in the left side of the interface. Do this for the product_prd and order_product_opr tables. After they are clicked, the tables appear in the center of the screen, with a list of fields. Between the product_prd and the order_product_opr table there is a one-to-many relation. To define the relation and create the JOIN code at the same time, drag and drop the id_prd field from the product_prd table onto the idprd_opr field. A blue arrow will display the relation visually:


     

  6. Now the query will retrieve all the products, and only details (from the order_product_opr table) for the ones that have associated fields. To restrict the results only to products that are actually involved in the order, right-click the arrow and select Edit. In the dialog box that opens, select the first option - Only include rows where joined fields are equal, and click Set.


     

  7. Next check all fields you want the query to retrieve: the name_prd and price_prd fields from the product_prd table, as well as the quantity_opr and idord_opr fields from the order_product_opr table.


     

  8. Now to filter the results, so that only the current order is retrieved: in the columns area, click the ... button next to the idord_opr column. In the dialog box that opens, select the Condition (equals), the Variable Type (session) and the Run-time Value (the reference for the session variable storing the order ID - kt_order_id).


     

  9. Click OK to close the dialog box. Then click the save icon to save the query for later use and close the MX Query Builder user interface (Query > Close).

  10. Back in Dreamweaver, you have to hit the Refresh button in order for the query to be displayed in the SQL area:


     

  11. Click OK once more to finish with the recordset.

  12. To display data retrieved by the recordset, you must use a dynamic table. Add one from the Application tab of the Insert bar. Configure it to use the rsOrders recordset created earlier and to display all records.


     

  13. From the page, remove the unwanted fields (the idord_opr one). Then change the header of the table (name_prd > Product name, price_prd >Price, quantity_opr > Quantity). Save the page and upload it to the server. After adding a few products to the order, click the view_order link. It will display a table with all added products:


     

  14. Next add some links that will allow the user navigate your site: one to the view_products page - Product list, one to complete the curernt order - to the complete_order page - and one to clear the current order - to the clear_order page. If you are using the files in the zip package, these links are already created; if not, you have to add them yourself.

Now the site front-end is finished and you can move on and create the administrative section, which will allow managing the orders.