Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

Step 5. Search and You Shall Find

Step 5. Search and You Shall Find

You’ve created your database, made your site dynamic, and linked the two together. You’re finished with the groundwork, so it’s time for some fun!

You’ll now create what is essentially a dynamic Search form that can pull up your data and display it based on keyword searches. Doing this even once will open up a new realm of ideas for your site – it means you know the basics of some cool tricks with site forms, and can display user data in interesting new ways.

A Dynamic Search Page

Make your Search page dynamic by opening the static search page you mocked up in Step 1. Open the Dynamic Bindings palette and choose the server scripting language you want (ASP, PHP, JSP) and click Convert Page. GoLive automatically renames the page’s extension to match what you selected.

From here you can add one or more Content Sources (the queries, remember?) to the head section. To get content, drag a Content Source object from the Dynamic Content palette to the head section of your Search page. Fill in the Inspector fields as follows:

  • Description: “Search_Results” (name it what you want, but this Content Source will hold our search results)
  • Type: ADO Database Query (or MySQL Database Query if using PHP/MySQL)
  • Choose the database name from the pop up menu (adobe, if using the example database)
  • Choose the table name from the pop up menu (golive_test, if using the example database)

Filter the Searches

At this point, the Search_Results Content Source will return ALL records from the database table we specified. But… what if we don’t want all records? You can now filter the Search_Results Content Source so it will only return records based on a user’s search request. GoLive provides a very nice visual way to do this via the Content Source Inspector. To get started:

  1. Link the search Form Action on your Search page to the file itself (index.asp or the name you gave it)
  2. Make sure the Form Method is “Get”, not “Post”
  3. Rename your text field on your search form to “lname” (or, the same name as the last name field of the sample database)
  4. Select “lname” from the Field Name list in the Content Source Inspector
  5. Choose Match request parameter ‘lname’ from the Match Pattern popup menu to the right in the Content Source Inspector
  6. Bind the table you created to display search results to the Search_Results Content Source using the Dynamic Bindings palette by:
  7. Selecting the table
  8. Clicking Replace Rows in the Dynamic Bindings palette
  9. Choosing Search_Results as the Content Source
  10. Setting it to display 5 records per page (this is for Block Navigation; more on this later)
  11. Bind the fields in the first row of the table to their appropriate fields in the database using the Dynamic Bindings palette. You only need to worry about the first row! The rest of the table will fill in automatically, because you checked “Replace Rows” in the Dynamic Bindings palette. You will bind the fields by selecting the mock content first name text and binding it to the first name field in the Dynamic Bindings palette. Do the same for the last name and phone number text in the first row of the table, binding them to their respective fields in the database.

What we’ve just done is tell our Content Source to kick back all the records whose last name field exactly matches what a user typed into your search form text field.