Home | SourceForge | Documentation | FAQ | What's New | To-Do List | Forums | Download | Contact

Sparse - Searching

Sparse not only allows you to navigate amongst data (by using sqlnavigation or the previous/next sqlaction buttons) it also allows you to search for specific values quickly and easily. You can navigate amongst the returned values the same way you can with regular ones! Here's a quick demonstration.

<sqltemplate database="myDB" tables="news" type="display" limit="5">
  <table border>
      <tr><th>Name</th><th>News Title</th><th>E-mail</th></tr>
      <tr><td><sqlfield name="name"></td>
           <td><sqlfield name="title"></td>
           <td><sqlfield name="email"></td>
Name: <sqlfield name="name" isSearch="true"> <sqlaction type="search">

That'll print out something like the following:

Name News Title E-mail
Daniel First Update!
Sarah Second Update!
Magic Johnson Update!
Terry Discworld Update!
Boutros I Can't Pronounce My Name

1 2 3 4 5

Now let's say you enter "Daniel" into the name search box. You'll come up with something like this:

Name News Title E-mail
Daniel First Update!
Daniel Site Updated.
Daniel E-mail change.
Daniel Now you can search with Sparse!
Daniel More updates to come.

1 2 3

Note that the search terms are appended (ANDed) to the existing constraints, and each search term is ANDed together (i.e. all terms must match). Search terms are substring matches (using SQL's "LIKE" syntax).

Finally, you can use the sqlsearch tag to streamline things. Similar to quick templates, sqlsearch replaces itself with several other tags. For example:

<sqlsearch names="name, email" />

will replace itself with

Name: <sqlfield isSearch="true" name="name" /> Email: <sqlfield isSearch="true" name="email" /> <sqlaction type="search" />

You can use Linking to search via a form or a URL from a different page - this is useful to e.g. show only a specific row as identified by ID.

Previous: Referencing Tags | Searching | Next: Sorting