close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

DataASssist Search Wizard

Thread began 11/21/2012 12:53 pm by thehalpeen319342 | Last modified 11/22/2012 5:39 am by thehalpeen319342 | 1161 views | 6 replies |

thehalpeen319342

DataASssist Search Wizard

Dear Jason,
Almost there!
I have created a search field/box on my results page and it works fine. However, if you press submit when the box is 'blank/empty' it displays all the records - which shouldn't happen if the box is 'blank/empty'.

How can I get this to display a message saying something like - "No results - you must enter search criteria in search box'.

I would also like to have a separate button that if pressed would show all records.

I hope that makes sense.

Sign in to reply to this post

Ray BorduinWebAssist

The search works as a filter, so without a filter the default is to return no results.

If you wanted a blank search to return no results, one option might be to automatically populate with a value that would have no result on the top of the results page:

<?php
if (isset($_POST['keywords"]) && $_POST['keywords"] == "") {
$_POST['keywords"] = "zznoresultszz";
}
?>



if this was added to the top of your results page and a field named "keywords" was submitted in your search it would search for "zznoresultszz" instead of a blank search and would return no results.

Sign in to reply to this post

thehalpeen319342

Thanks, that worked - excellent. Just wondering, what about a 'show all records' button.

Sign in to reply to this post

thehalpeen319342

Thanks, that worked - excellent. Just wondering, what about a 'show all records' button. See attached for what I mean.

Attached Files
search all.pdf
Sign in to reply to this post

Ray BorduinWebAssist

You could probably add a url parameter in your show all link like:

<a href="results.php?showall=1">show all</a>

Then on the top of the results page add code:

What are you using for the trigger for your filter on the results page? Assuming it is the button named "submitButtonName"

<?php
if (isset($_GET['showall'])) {
$_POST['submitButtonName'] = 1;
}
?>

Sign in to reply to this post

thehalpeen319342

Thanks for that. It's early morning here - Ill give it a go tomorrow.

Sign in to reply to this post

thehalpeen319342

Dear Ray, I replaced 'submitButtonName' with 'WADbSearch1' which is the name on the submit button, and it worked. So thanks once again for that.

Sign in to reply to this post

msbannister373603

Show No Results if No Search Criteria Chosen

Trying to use the following directions to restrict the results when no search criteria is chosen. I added this to my results page and I get an error message when I do so. Also, not sure I understand what field keywords need to be added to. Can you further explain because I'm trying to accomplish the same thing.

Thanks

The search works as a filter, so without a filter the default is to return no results.

If you wanted a blank search to return no results, one option might be to automatically populate with a value that would have no result on the top of the results page:


Code:
<?php
if (isset($_POST['keywords"]) && $_POST['keywords"] == "") {
$_POST['keywords"] = "zznoresultszz";
}
?>if this was added to the top of your results page and a field named "keywords" was submitted in your search it would search for "zznoresultszz" instead of a blank search and would return no results.

Sign in to reply to this post

Jason ByrnesWebAssist

in the example code, there is a form element named keywords and the search form is posting to the results page using the POST method.


the idea is to use an if statement to see if the keywords form element in the search form is blank:
if (isset($_POST['keywords"]) && $_POST['keywords"] == "") {


if it is left blank in the search form, then set the value to a nonsensical value that wouldn't appear in your database:

$_POST['keywords"] = "zznoresultszz";

this will cause the search to look for a value that doesn't exist, thus returning no records.

Sign in to reply to this post

msbannister373603

Still not working

Still can't get this to work. When I add the code at the top of the page I get an error message. I also add the keyword in a hidden field on the search page. Maybe I'm missing something obvious but can't get it to work. Can you provide a more detailed instruction.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...