close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Web development tutorial

How to enable sorting of dynamic data

Tutorial created by Kate Ford

Categories: Data Bridge, Dreamweaver, PHP


Give your website visitors a method to sort database-driven dynamic data on your result pages. In this tutorial, I will demonstrate how to add links to your column headers that allow for sorting.

arrow downWhat do you need to start?

  • Dreamweaver 8 or newer
  • Data Bridge (alternately, DataAssist 2.0 or higher) installed and activated in Dreamweaver
  • Dreamweaver dynamic site (PHP)
  • Connection to your MySQL database
  • Recordset of data to update your table + table of database-driven content of 2 or more columns
    In this tutorial, we will use the product results page created by the Data Bridge product administration preset. This will automatically generate the recordset and table that you need. If you have Data Bridge automatically generate your product tables, be sure to insert products into your database table. This way when you get to the final step, you will have data to view and sort.

You can follow along with my examples using the same preset. Once you learn this concept, it can be applied to other pages.

arrow downPrepare your page for sorting

Before applying the sort server behavior, you need to remove any sorting previously applied to the recordset.

In Bindings, doubleclick Recordset (WADAproducts).

This opens a Recordset dialog with the recordset that was automatically generated using the DataAssist wizard.

In this tutorial, the recordset is displayed in Simple mode. To remove any sorting previously applied to the recordset, go to Sort and select None.

However, if your recordset is displayed in Advanced mode, you will want to remove any ORDER BY clause.

When you are done with this step, click Test to test your SQL statement.

Click OK.

arrow downAdd links to column headers

Now it's time to add links to column headers so that data can be sorted. To trigger the sort, a link needs to be added to the current page for each column header you want to sort.

Select a column header. (For example: Name)

Then select the link folder icon in the Properties panel.

With the Select File box open, select the radio button labeled File system. (In some versions, Dreamweaver automatically opens the file system.)

Choose the products_results file from the admin folder.

Click Parameters.

Type sort in Name and ProductName in Value. (The entry in Value should match the database column name you want to sort.)

When finished, click OK.

The final step in this section is to add a QueryString Binding.

The QueryString Binding option makes the parameter available for triggering the sort and allows you to filter URL parameters for more complex sorting operations.

Go to the Bindings panel and click +.

Select QueryString Binding which opens the Filtered URL Parameter box. Type sort into Parameter name.

Click OK.

Save the page. (Ctrl or Cmd + S)

arrow downAdd the sort server behavior

Now that the page set-up is complete, we'll add the sort server behavior next.

From the Server Behaviors panel, click +.

Scroll down to WebAssist, then DataAssist, and click Sort.

When the Sort dialog box opens, click the Trigger lightning bolt icon.

After the dialog box opens, expand the QueryString Data binding and choose sort.

Click OK.

Back in the Sort dialog box, make sure WADAproducts is selected for your recordset.

Because DataAssist has already created the correct Session variable, leave the default entry.

To toggle the sort between ascending and descending, check the Toggle sort on subsequent visits box.

Under Sorting in the dialog box, click +.

Then click the Column lightning bolt icon.

When the dialog box opens, select sort under QueryString Data.

Click OK.

Choose the Sort order from the available options. (For example: Ascending)

Click Finish.

Save your page. (Ctrl or Cmd + S)

Preview the page in your browser. Now you can click on the Name column header to sort the data in your table.

arrow downReviews and comments

Comments will be sent to the author of this tutorial and may not be answered immediately. For general help from WebAssist, please visit technical support.

Sign in to add comments

JBWebWorks: 4 Years, 1 Week, 5 Days, 8 Hours, 11 Minutes ago

Wanted to know how to sort on multiple columns i.e. productName and productPrice with a single click?


Team WebAssist: 4 Years, 1 Week, 5 Days, 3 Hours, 10 Minutes ago

JBWebWorks: This tutorial shows you how to sort on productName. You'd repeat the steps for each column you want to allow the clickable sorting for.

Web Designer Troy: 3 Years, 10 Months, 1 Week, 2 Days, 19 Hours, 57 Minutes ago

Is there a way to anchor to part of a page after the sort and still maintain the toggle? The URL parameter : "...myfile?sort=id#someanchor..." works, but kills the toggle option.

(I'm trying to avoid Javascript.)

erinlima318673: 9 Months, 6 Days, 4 Hours, 3 Minutes ago

Is there a way to make this work with a customer-facing results page, showing product images and descriptions in a repeat region? I want to allow my customers to sort the results by price ascending and descending, and my make. I have gone through the tutorial umpteen times and can't get the results in the repeat region to change at all.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.