Showing Records from a Database in Opus

Databases are often used to store information, such as product information, historical facts, travel information, price information, employee information, and much more. With Opus Pro you can display this information in a more attractive and stimulating environment as well as allow users to navigate around the database.

Note:
This section describes the general principle of how to display records from a database to a user in your publication. You should be familiar with how to connect to a database with the Database Query action before you read this section – see Database Query action for more information.

To show records from a database:

  1. First you need to decide how the information will be displayed. Will the first record appear as they enter the page or do they press a button to show the records?

If you want to have the first record appear on the page as soon as the page is displayed, use an On Showtrigger on the page’s Actions dialog.

  1. Select the Database menu from the Actions tab.

  2. Add the Database Query action to your trigger, as described in adding actions. The Database Query tab will automatically appear when you add the action.

Note:
The Database Query action is used to connect to the database and set up a Query so you can create a Select List of records that you want from the database.

  1. The Database Query action also performs one more vital role; it is used to match a field from your database to a variable name in your publication.

Note:
What this means is that the contents of the field of the current record will be added to the contents of the variable you asked it to save it in –see the Field / Variable panel in the Database Query action.

  1. When you have filled in the Database Query action, you will need to create Text objects on the page in which the data from the first record in the database will be displayed – see Example.

  2. Use the Insert Variable tool to add the variable to a Text object. Right-click on the Text object to open the right-click menu and select Insert Variable or Expression option – this will open the Insert Variable or Expression dialog in which you can select the name of the variable you assigned to the Field / Variable panel in the Database Query action.

Note:
Add as many text boxes as there were fields in the Database Query action and add the same variable name you assigned in the Field / Variable panel.

  1. You can format each text box just like any other, you may want to add a border or change the font size. You can add transitions and effects or show and hide the text field as you would with any other Text object.

  2. That’s it! How it works is that when the page is displayed, the On Show trigger activates the Database Query action that then connects to the database and creates a list of records that match the criteria you set. Next it gets the first record from the list and adds the contents from each of its fields to the variables that you set up to store the data. Finally, it displays the contents of the variable in the Text objects in which you inserted the variable name.

Related Topics:

the Database Query action

Working with Databases - Overview

Introducing the Database Actions