DMXzone Database Updater PHP Support Product Page

displaying a record from a search box

Asked 28 Jul 2017 07:12:26
1
has this question
28 Jul 2017 07:12:26 dougie coulter posted:
the simplified question is...
I need a search box to query a single column and return the record if it hits a match or return a "no items found" message if it doesn't. (it will be a unique field so it'll only ever find one record (or not)) I don't want to display all records then filter them down based on a text box as per the closest video tutorial I can find.

can you point me in the direction of a solution. I've scoured through all the videos and manuals but haven't found anything related.

hope you can help

duggy

Replies

Replied 28 Jul 2017 13:00:06
28 Jul 2017 13:00:06 Teodor Kuduschiev replied:
Hi Dougie,
Should the results be displayed on the same page?
What condition are you using to filter the query - contains, or equals to?
Replied 28 Jul 2017 16:06:39
28 Jul 2017 16:06:39 dougie coulter replied:
Hi Teodor

The end-plan is to have a date picker which will query a date column and return a message eg "I'm sorry that date is unavailable" (if one already exists.) or "yes, that date is available" if it doesn't find a match.

I figured that a reasonable way to workaround my limited knowledge would be to automatically add a text field "I'm sorry that date is unavailable" to each db record and simply return that field. The "yes that date is available" is essentially just a custom "no records found."

So to answer your question, the filter will most certainly be "equal to" and it doesn't matter if it's on the same page or not. Whichever is easiest.

does that help?

duggy
This reply was removed on 8/6/2017 5:46:33 AM.
See the changelog
Replied 02 Aug 2017 07:20:01
02 Aug 2017 07:20:01 Teodor Kuduschiev replied:
Hello Dougie,
Sorry for the delayed reply, i was off the office the last couple of days.

In order to show a "no results available" text, just follow this tutorial:
www.dmxzone.com/go/32811/show-or-hide-elements-on-your-page-when-a-query-returns-no-results

As for showing the record, only when the query is filtered - just follow the tutorial explaining how to filter queries using a text box, but when setting up your query filter - add a condition also. For the condition use the same value as you are using for the filter value. Example:

This way the filter will only be triggered, when the condition is met i.e. when a value is entered, the filter will be applied, and then the results will be displayed.
Replied 02 Aug 2017 08:58:12
02 Aug 2017 08:58:12 dougie coulter replied:
Thanks for this, I'll follow your instructions and get back if I encounter any difficulty.

d
Replied 02 Aug 2017 09:42:46
02 Aug 2017 09:42:46 dougie coulter replied:
ok, I've had a scan through the suggested tutorials but they're missing the crucial info necessary for me to adapt them to suit my needs.
Let me strip it back.

Date picker & submit button which when clicked, returns the record matching the date selected.

The "filter a query using text box" tutorial starts with displaying a repeating region showing all db records which is exactly what I DON'T want to do.
Replied 02 Aug 2017 10:54:59
02 Aug 2017 10:54:59 Teodor Kuduschiev replied:
When using this expression in the condition field, nothing will get returned in the repeat region, until a value is submitted in the form ....
Replied 06 Aug 2017 06:37:33
06 Aug 2017 06:37:33 dougie coulter replied:
Hi Teodor,

Adding that condition is actually part of the tutorial already. The only difference I can see with yours is the use of "=" rather than "contains" but this doesn't stop the repeat region being populated as soon as the page loads. it just means that it all disappears on the first key-stroke and doesn't return a result until it gets a full match.

Would it be easier to append a ?id= link with the text box data and display the results on a different page?

duggy
Replied 07 Aug 2017 07:02:33
07 Aug 2017 07:02:33 Teodor Kuduschiev replied:
Hi Dougie,
Yes, my mistake - in order to show them only on match you don't need to use the condition, just remove it, and use the = operator. Then it won't render the query results on the page, unless it finds a match, when you enter something in the field on the page.

Reply to this topic