<form name="nameofformhere" method="post" action="#xarservergetcurrenturl()#">
</form>
(If you are posting the data to the same page - easier to begin with as it permits you to see the results!)
OR
<form name="nameofformhere" method="post" action="&xar-baseurl;index.php/pageyouaregoingto">
</form>
(If you are posting the data to a different page)
<fieldset>
<legend>
Title goes here
</legend>
</fieldset>
(Legend is a lable for that group of form inputs, or if you only have one field set, for that form)
<label for="textinputname" class="xar-form-label">
Lable for the textinput
</label>
<input id="textinputid" type="text" size="30" name="textinputname">
(generally easier if you make the text-input-id and text-input-name the same :) )
So, we should have.....
<form name="nameofformhere" method="post" action="#xarservergetcurrenturl()#">
<fieldset>
<legend>
Title goes here
</legend>
<label for="textinputname" class="xar-form-label">
Lable for the textinput
</label>
<input id="textinputid" type="text" size="30" name="textinputname">
</fieldset>
</form>
Thats the input dealt with.
Now to get the information out of it...
((TO BE MOVED))
<xar:set name="temptextinputname">xarVarFetch('textinputname', 'str', $textinputname, NULL, XARVAR_NOT_REQUIRED)</xar:set>
((TO BE MOVED))
(we are making a temporary <set>, taking the inputted value, ("textinputname"), stating it is in String Format, making it a Variable("$textinputname"), then something about NULL, and XARVAR_NOT_REQUIRED)
Now, if we want to display our new Variable... we can use the ## tags...
Yet for could practice, we shall wrap it within and If/Else condition check so as to avoid errors...
((TO BE MOVED))
<xar:if condition="empty($textinputname)">
Then nothhing should happen!
<xar:else />
#$textinputname#
</xar:if>
((TO BE MOVED))
(Thus, if there is no value in the variable($textinputname is EMPTY), then nothing happens, if it is not empty, then we display the value!)
OR
((TO BE MOVED))
<xar:if condition="!empty($textinputname)">
#$textinputname#
<xar:else />
Then nothhing should happen!
</xar:if>
((TO BE MOVED))
(basically the reverse of the previous code. By adding a ! infront of the empty , we are stating if NOT EMPTY, the output our vlaue, otherwise, being EMPTY, do nothing!)
(no real difference, just sometimes it is easier to check on the negative rather than the positive etc.)
Now, that means you have a small form with a text input field, that if filled in and submitted, will post the data back to the same page, and tell you what was typed in!
Now, what if we want to run a DD Query / Search ?
Well, we have already managed to make a conditional check with the If / Else to output the value... so we can progress from there and instead of outputted the value; so we need the data formatted so as to be acceptable to the where="" ...
So, we want to find an exact match, something equal to what was typed in...
((TO BE MOVED))
<xar:if condition="!empty($textinputname)">
<xar:set name="searchtextinputname">'ddname eq \'' . $textinputname . '\''</xar:set>
<xar:else />
<xar:set name="searchtextinputname">"ddname LIKE '%'"</xar:set>
</xar:if>
#$searchtextinputname#
((TO BE MOVED))
(Now the above is a little clever, as it is doing one of two things... if a value is set, (our Variables is NOT EMPTY), ten we are creating a string for an "equal to" search.
On the other hand, if our value is not set, (it is EMPTY), then we tell it to look for anything!)
Right, so there we go... a basic little setup.
Which should look like this....
<form name="nameofformhere" method="post" action="#xarservergetcurrenturl()#">
<fieldset>
<legend>
Title goes here
</legend>
<label for="textinputname" class="xar-form-label">
Lable for the textinput
</label>
<input id="textinputid" type="text" size="30" name="textinputname">
</fieldset>
</form>
<xar:set name="temptextinputname">xarVarFetch('textinputname', 'str', $textinputname, NULL, XARVAR_NOT_REQUIRED)</xar:set>
<xar:if condition="!empty($textinputname)">
#$textinputname#
<xar:else />
Then nothhing should happen!
</xar:if>
<xar:if condition="!empty($textinputname)">
<xar:set name="searchtextinputname">'ddname eq \'' . $textinputname . '\''</xar:set>
<xar:else />
<xar:set name="searchtextinputname">"ddname LIKE '%'"</xar:set>
</xar:if>
#$searchtextinputname#
So, to test, make sure you are posting to the same page as your search form.
Then go though and replace the "names" to match your needs.
PLEASE make sure you change ALL the names to fit, otherwise you will get errors etc.
Once you have the data you put in showing up....
then you can post it to a different page!
Simple replace the Form Action from current-url to baseurl+whatever your page is ( as given at the start! ), and copy the Code marked as ((TO BE MOVED)) to your Results page.
so in one file (your search file...)
<form name="nameofformhere" method="post" action="#xarservergetcurrenturl()#">
<fieldset>
<legend>
Title goes here
</legend>
<label for="textinputname" class="xar-form-label">
Lable for the textinput
</label>
<input id="textinputid" type="text" size="30" name="textinputname">
</fieldset>
</form>
and in your other file, (your results form...)
<xar:set name="temptextinputname">xarVarFetch('textinputname', 'str', $textinputname, NULL, XARVAR_NOT_REQUIRED)</xar:set>
<xar:if condition="!empty($textinputname)">
#$textinputname#
<xar:else />
Then nothhing should happen!
</xar:if>
<xar:if condition="!empty($textinputname)">
<xar:set name="searchtextinputname">'ddname eq \'' . $textinputname . '\''</xar:set>
<xar:else />
<xar:set name="searchtextinputname">"ddname LIKE '%'"</xar:set>
</xar:if>
#$searchtextinputname#
Okay.... so one page for input.... the other page fetches it
whats that you say..... you want to search on more than one item?
Okay....
we go back to testing the input and output on the same page (it's easier!).
we add some new inputs to our input form....
How about a select... "Please choose one of the following" sort of thing...
<label for="selectinputname" class="xar-form-label">
selectinputnamehere
</label>
<select name="selectinputname">
<option value="" selected>None Selected</option>
<option value="valuefordata">Value In the list displayed</option>
<option value="valuefordata">Value In the list displayed</option>
<option value="valuefordata">Value In the list displayed</option>
<option value="valuefordata">Value In the list displayed</option>
<option value="valuefordata">Value In the list displayed</option>
<option value="valuefordata">Value In the list displayed</option>
</select>
and the data-fetching code etc...
<xar:set name="tempselectinputname">xarVarFetch('selectinputname', 'str', $selectinputname, NULL, XARVAR_NOT_REQUIRED)</xar:set>
<xar:if condition="!empty($selectinputname)">
#$selectinputname#
<xar:else />
Then nothhing should happen!
</xar:if>
<xar:if condition="!empty($selectinputname)">
<xar:set name="searchselectinputname">'ddname eq \'' . $selectinputname . '\''</xar:set>
<xar:else />
<xar:set name="searchselectinputname">"ddname LIKE '%'"</xar:set>
</xar:if>
#$searchselectinputname#
It's that simple!
Maybe something different to an "equal to" ?
okay.... how about.... "Starts with"
<xar:elseif condition="!empty($namehere)" />
<xar:set name="searchnamehere">"ddname LIKE '$namehere%'"</xar:set>
thats the basics....
And, as it's bound to come up..... if you want to string a bunch of "search values" togeths.... (A = "1", B = "red", C startswith "nut".. .etc...
All you do is set a new Variable, with your created Search pieces in it....
<xar:set name="yoursearch">$searchtextinputname . ' and ' . $searchselectinputname</xar:set>
AND.... Just incase you want to do a more complicated search... with OR's as well as ANDS...
<xar:set name="yoursearchpart1">'( ' . $searchtextinputnamea . ' or ' . $searchselectinputnamea . ' )'</xar:set>
<xar:set name="yoursearchpart2">'( ' . $searchtextinputnameb . ' or ' . $searchselectinputnameb . ' )'</xar:set>
<xar:set name="yoursearchfull">$yoursearchpart1 . ' and ' . $yoursearchpart2</xar:set>