Insert new values into the database

In this topic you will learn how to create a page that allows adding new entries to the database. You will use the Insert Record Form Wizard and the Comma-Separated CheckBoxes widget to enhance it.

 

To create the page you must:

  1. Create the basic insert form which uses a textfield for the list of languages.

  2. Use the Comma Separated Checkboxes to replace the tex-field added earlier with a set of check boxes from the correct table.

 

Create the basic insert form for adding entries.

To create the insert form, follow the steps below:

  1. Open the insert page in Dreamweaver.

  2. Go to the MX Kollection tab of the Insert bar and click on the Insert Record Form Wizard icon.

  3. The wizard interface is divided into three steps which must be configured.

  4. In the first step define the database information, as shown below:

  5. In the second step of the wizard define the columns to insert into and what form elements to display:

  6. In the last step of the wizard define validation rules for the fields involved in the transaction:

  7. The wizard adds HTML code for the insert form and server behaviors to handle the application logic - the insert operation and the field validity.

To test the page save it and press F12 to load it into the browser:

 

Note: If using a remote server you might also need to upload the includes folder that was created by MX Kollection.

 

Enhance the insert form: pick languages from the database

After creating the basic form you will notice that in order to set the languages that one student wants to learn you have to manually enter their ID's. And this is highly unpractical - you would need to know the exact ID's by heart. To make it easier, the text field will be replaced with a group of checkboxes - each corresponding to one entry in the language_lan table.

First you must create a recordset that retrieves all entries in the language_lan table:

  1. Open the insert page in Dreamweaver.

  2. Go to the Bindings tab of the Application panel > Plus(+) > Recordset (Query). Configure the user interface that loads as shown in the image below:


     

  3. Click OK to close the user interface and create the recordset.

Next you have to replace the regular text field with a widget:

  1. Open the insert page in Dreamweaver.

  2. Click on the Languages text field to select it.

  3. Go to the Server Behaviors tab of the Application panel > Plus(+) > MX Kollection > Form Controls > Comma Separated Checkboxes.

  4. Configure the user interface that loads:

If you want to test the page, save it and press F12 to load it into a browser. The text field has been replaced by a set of checkboxes.

 

 

After adding a new record, the languages_std column of the student_std table will contain the values of the id_lan columns for the checked options:

 

 

Next you will learn how to display all entries in the database - with the name and the name of the foreign language courses to attend.