Use the [Search] context with [founditems] to easily retrieve records from your databases.
[search Criteria]
[founditems]Search results[/founditems]
[/search]
[search db=xx.db&eqCITYdata=Chicago]
Your search found [numfound] items
[founditems]
<img src="[Picture]">
[Name], [Address], [City]
[/founditems]
[shownext]
previous/current/next page links go here
[/shownext]
[/search]
Tag | Description |
---|---|
[NumFound] | A number indicating how many records matched the search request. |
[sum field=fieldName] | Calculates the numerical sum of all the found records, using the fieldName column. |
[avg field=fieldName] | Calculates the numerical average of all the found records, using the fieldName column. |
[min field=fieldName] | Calculates the numerical minimum of all the found records, using the fieldName column. |
[max field=fieldName] | Calculates the numerical maximum of all the found records, using the fieldName column. |
[founditems]...[/founditems] | Normally you place a [founditems] loop inside a [search], so you can display all the matching records. You can put any database field names inside the [founditems] loop to display them in the HTML. |
[replacefounditems]...[/replacefounditems] | Loops though all the found items and replaces text in each record with the specified new text. |
[shownext]...[/shownext] | Creates a list of links that let visitors see 'chunks' of search results. |
[search db=yourdatabase&CityData=Chicago&
ZipCodeSumm=t&ZipCodeSort=1&max=25&startat=[starthere]]
db=yourdatabase
OR
table=tablename
CityData=Chicago
LastNameSort=1
ZipCodeSumm=t
DeadlineType=date
ClassTimeType=time
InventoryType=num
max=25
startat=76
eqStateData=New York&geCountyPopData=20000
eqStateDatarq=New York&gecountiesDatarq=20
typically "and" will find fewer matches in a database, because it is more restrictive -- the chances of finding a house that matches all 3 criteria simultaneously is far lower than finding a house that matches any one of the criterion individually.
FirstName is Grant and LastName is Hulbert | eqFirstNamedatarq=Grant&eqLastNamedatarq=Hulbert |
Bedrooms > 5 and fireplace is True and Bathrooms is 2 | grBedsdatarq=5&eqFireplacedatarq=T&eqBathsdatarq=2 |
You can make all fields required in one simple step by putting "AllReqd=T" into the form.
you can also embed a [search] context in a template. Any browser accessing that HTML page (no special commands required - just link to the page) will see the 'live' search results. It might look like the following
<BODY>
Here's an embedded search:<br>
[search db=People.db&eqFirstNameDatarq=Grant&eqLastNamedatarq=Hulbert]
[founditems]
[FirstName], [Address], [City], [State], [Zip]<br>
[/founditems]
[/search]
</BODY>
grCountyPopData=20000
eq | equal to |
ne | not equal to |
gr | greater than. |
ge | greater than or equal to |
ls | less than |
le | less than or equal to |
rn | range. Specify two values separated by spaces (or any other delimiter specified by wbrk; i.e., ...&wbrk=,&...). The values may be dates, numbers, or text. If date, time or number, you must specify what type of data by using fieldnametype=xxx (where xxx is num, date or time). Example: rnBirthdaydata=02/28/2008 08/31/2008&Birthdaytype=date Note: When specifying a range, the smaller value must precede the larger value, i.e. rnZipCodedata=92069 93090, not rnZipCodedata=93090 92069. |
mr | minimum range value: if no maximum then ge is used instead |
mx | maximum range value: if no minimum than le is used instead |
cl | close to (numeric only). clZipCodedata=92069&clZipCodedata=10 finds all records whose ZipCode field is within 10 of 92069 (92059 - 92079) |
bw | begins with |
ew | ends with (from 8.6) |
ws | Interpret the words as a single string to be matched (including spaces etc.) This lets you find entire phrases, like "Joe enjoys butter" only if those 3 words are next to each other in that order, including spaces (unlike wa and wo, below) |
wa | Separate the words and "and" them together (all must match). Searching for 3 words using wa will match only if all 3 are in the field, but not necessarily next to each other. |
wo | Separate the words and "or" them together (at least one must match - default option for text). Search for 3 words using wo will match if any one of them matches. |
wn | word not equal - none of the words match text in the specified field |
Word breaks: Use Wbrk to define what constitutes a word. By default, a space is a word delimiter, but you can define your own delimiter(s) using wbrk; example: fieldnameWbrk=,-;. | |
Word position in field: Use Word to define where you want the word to be found. Example: fieldnameWord=ww | |
ss | SubString match. Looks for word anywhere, even inside larger words. Finds "I like typographic conventions" and "This is a graphic" and "Graphical user interfaces are cool." |
ww | Whole Word match. Looks for whole word; ignores if found inside a larger word. Finds "This is a graphic" |
sw | Start of Word. Looks for word at the beginning of words. Finds "This is a graphic" and "Graphical user interfaces are cool." |
Case sensitivity: Conducts case sensitive searches. Examples: fieldnameCase=t AllCase=t (apply to all fields) | |
Finding Empty Fields and Find All [blank] is a special WebDNA tag available in searches to explicitly find empty records. In practice, it is more often used to find records which are NOT empty, which is one way to "find all". Here are two popular ways to Find All: nefieldnameDatarq=[blank] nefieldnameDatarq=FindAll The second example, of course, assumes you don't have a field value of FindAll. Alternately, you can use the form FieldNameBLNK=T, which makes it possible to use radio buttons or checkboxes to let the visitor decide how they want to search for blank fields. If you want to apply this to all the fields in your search at once, then set allBLNK=T. |
group1field=title+description+keywords&wogroup1data=Bird
group1field=zipcode&group2field=zipcode
negroup1datarq=08055&rngroup2datarq=08001 08099
When assigning groups, you must name them sequentially, without skipping numbers.
If you plan to work on several groups, the groupfields definitions must be placed at the beginning of the search string. For instance
group1field=title+description&wogroup1data=Bird&group2field=title+keyword&wogroup2data=Bird
has to be written in this order:
group1field=title+description&group2field=title+keyword&wogroup1data=Bird&wogroup2data=Bird
StateSort=1&CitySort=2
StateSort=1&deCityPopSort=2&CityPopType=num&CitySort=3
You cannot skip a number in the sorting hierarchy.
as | ascending (the default, if nothing specified) |
de | descending |
ra | random |
Maintain randomness: Sometimes you need a series of random sorts to always present the exact same 'random' order. You can force the randomizer to return items in the same order if you add another parameter "RandSeed=879" (or any other integer number). This is most helpful when you use [shownext] and you need each successive set of links to predictably return the results in the same order. RandSeed=integer | |
No sorting at all: Results are displayed in exactly the same order they appear in the database file. Rank=off |
[search db=yourdatabase.db&neStatedata=[blank]&StateSort=1&StateSumm=t]
[founditems]
<b>[State]</b> <p>
[search db=yourdatabase.db&eqStatedata=[state]&CitySort=1]
[founditems]
[city], population [citypop] <br>
[/founditems]
[/search]
[/founditems]
[/search]
[search db=yourdatabase.db&neStatedata=[blank]&StateSort=1&StateSumm=t]
[founditems]
<b>[State]</b>
[search db=yourdatabase.db&eqStatedata=[state]]
has [numfound] cities.<p>
[/search]
[/founditems]
[/search]
You can define your own custom list of word break characters with . By adding Descriptionwbrk=.,- to your search causes user-entered text surrounded by those characters in the HTML form field Description to be considered as individual words.
[search db=somebase.db&woDescriptiondata=graph&Descriptionword=sw&]
word | |
---|---|
ss | Descriptionword=ss looks for "graphic" and finds it anywhere inside phrases such as: "I like typographic conventions" and "This is a graphic" and "Graphical user interfaces are cool." |
ww | Descriptionword=ww looks for "graphic" and will not find it inside phrases such as: "I like typographic conventions". It will be found inside "This is a graphic." |
sw | Descriptionword=sw looks for "graphic" at the beginning of words, like "This is a graphic" and "Graphical user interfaces are good", but will not find it inside "I like typographic conventions." |
woDESCRIPTIONdatarq=2&DESCRIPTIONword=WW&DESCRIPTIONfbrk=[url],[/url]
Basically, "wbrk" tells WebDNA how to break up the values you pass in your search context, while "fbrk" tells WebDNA how to break up the values stored in the database.
Terry WilsonDOWNLOAD WEBDNA NOW!
Amazon Web Services (AWS) README for Machine Image ID...
Technical Change HistoryThis Technical Change History provides a reverse chronological list of WebDNA changes...
[biotype]BioType is a behavioral biometrics WebDNA function based on ADGS research and development (from version 8...
F.A.QA compilation of some user's questions...
WebDNA reference...
WebDNA ModulesA list of the currently available modules...
Explicitly define a block of WebDNA code that has a separate variable space...
[orderfile]Displays the contents of a shopping cart...
[setlineitem]Modify an existing line item in an order file...
[boldwords]Highlights matching words with boldface HTML tags...
[shell][shell] is a way to use the command line with your webserver...
[referrer]Displays the URL of the referring page...