Appearance
Search Form
A search form allows users to search on specific fields. Implementing one involves two steps:
- Creating a search form
- Adding search fields to the WHERE clause
Creating a Search Form
You can create search forms in many ways. Many plugins make this easy, but you can also build your own using HTML.
Below are two simple examples in plain HTML. The first uses a search box that accepts free text. The second contains a drop-down list. A drop-down list has the advantage of using exact matches, which is usually faster than wildcard searches and can improve performance on large tables.
✨ Example: Search Form With Input Field
html
<form method="POST" action="/app-path/">
<input type="search" name="book_author">
<input type="submit">
</form>✨ Example: Search Form With Drop-Down List
html
<form method="POST" action="/app-path/">
<select name="book_author">
<option>Brandon Sanderson</option>
<option>Joe Hill</option>
<option>Leo Tolstoy</option>
<option>Martha Wells</option>
<option>Stephen King</option>
</select>
<input type="submit">
</form>Adding Search Fields to the WHERE Clause
Your search form sends user input to your app, which can access it as URL parameters. The form method (POST in the examples above) determines how you access the submitted values. (Read more...)
The URL parameters are added to the query using the WHERE clause in the Table Builder. This is where you define whether searches must be exact or use wildcards, and whether a URL parameter is required. (Read more...)
✨ Example: Wildcard Search
This search requires the book_author URL parameter. Without a URL parameter, the query returns no rows.
sql
WHERE book_author = concat('%', httpPost['book_author'], '%')✨ Example: Exact Match
This query uses the book_author URL parameter when it is available. If the parameters is not available, the query returns all rows.
sql
WHERE book_author = IFNULL(httpPost['book_author'], book_author)Notes
- The demonstrated features work in both the free and premium versions.
- Use httpGet to support form method GET.
- Use httpRequest to support both form methods GET and POST.
