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

Searching thru more than one field

Thread began 1/11/2019 3:27 pm by lr_leal239405 | Last modified 1/18/2019 8:34 am by lr_leal239405 | 26 views | 13 replies |

lr_leal239405

Searching thru more than one field

I'd like to unite the Search code that asks for two input fields but turn it into one search field that looks thru two columns. I think you told me once but I can't remember. I have the following:

<label for="ss_title" class="sublabel" >Title:</label>
<input id="ss_title" name="ss_title" type="text" value="<?php echo((isset($_GET["ss_title"])?$_GET["ss_title"]:"")); ?>" class="formTextfield_Medium" tabindex="4" title="Please enter a value.">
</div>
<div class="lineGroup">
<label for="ss_keywords" class="sublabel" >Keywords:</label>
<input id="ss_keywords" name="ss_keywords" type="text" value="<?php echo((isset($_GET["ss_keywords"])?$_GET["ss_keywords"]:"")); ?>" class="formTextfield_Medium" tabindex="5" title="Please enter a value.">
</div>

I want to have one search field look thru both columns instead. Thanks!

Sign in to reply to this post

Ray BorduinWebAssist

If you use the Database Search server behavior and choose type "keyword", then you can multi-select the columns to search and use a single field.

Sign in to reply to this post

lr_leal239405

I got the server behavior -> + -> Webassist -> MySQLi -> MySQLISearch.

Tried a couple of times with below code but keep getting all the records. What am I doing wrong? Thank you.

FIRST TRY:

<?php
$searchWADAss_templates_WADbSearch1 = new WA_MySQLi_Search("WADAss_templates","0=0");
if (isset($_GET["Search"]) || isset($_GET["Search_x"])) {
$searchWADAss_templates_WADbSearch1->clearSearch();
$searchWADAss_templates_WADbSearch1->setSearch(array("type"=>"Key", "comparison"=>"=", "join"=>"AND", "and"=>", ", "or"=>" ", "start_encap"=>"\"", "end_encap"=>"\""), array("ss_title", "ss_keywords"), "s", "");
}
?>


SECOND TRY:

<?php
$searchWADAss_templates_WADbSearch1 = new WA_MySQLi_Search("WADAss_templates","0=0");
if (isset($_GET["Search"]) || isset($_GET["Search_x"])) {
$searchWADAss_templates_WADbSearch1->clearSearch();
$searchWADAss_templates_WADbSearch1->setSearch(array("type"=>"Key", "comparison"=>"Includes", "join"=>"AND", "and"=>", ", "or"=>" ", "start_encap"=>"\"", "end_encap"=>"\""), array("ss_title"), "s", "");
$searchWADAss_templates_WADbSearch1->setSearch(array("type"=>"Key", "comparison"=>"Includes", "join"=>"AND", "and"=>", ", "or"=>" ", "start_encap"=>"\"", "end_encap"=>"\""), array("ss_keywords"), "s", "");
}
?>



FORM LOOKS LIKE THIS:

<div class="lineGroup">
<label for="ss_keywords" class="sublabel" >Keywords:</label>
<input id="ss_keywords" name="ss_keywords" type="text" value="<?php echo((isset($_GET["ss_keywords"])?$_GET["ss_keywords"]:"")); ?>" class="formTextfield_Medium" tabindex="5" title="Please enter a value.">
</div>

Sign in to reply to this post

Ray BorduinWebAssist

The first try looks correct. Is your form method="post" or is it method="get"? The trigger might be wrong.

Sign in to reply to this post

lr_leal239405

This below. It's get. I changed to post but does the same.

<form class="Basic_Default" id="Search_Basic_Default" name="Search_Basic_Default" method="get" action="spec_sheets_results.php">


<div class="lineGroup">
<label for="ss_keywords" class="sublabel" >Keywords:</label>
<input id="ss_keywords" name="ss_keywords" type="text" value="<?php echo((isset($_GET["ss_keywords"])?$_GET["ss_keywords"]:"")); ?>" class="formTextfield_Medium" tabindex="5" title="Please enter a value.">
</div>

attached is the file:

Sign in to reply to this post

Ray BorduinWebAssist

Please attach the search page as well... "get" was correct based on your code. I just wanted to make sure it wasn't set to post.

Sign in to reply to this post

lr_leal239405

That page has the search and is the search results as well, so that attachment should have everything. Thanks.

(So just to reiterate....the search works fine when I had the fields separate for Title and Keywords. It's only with this new code to look thru both in one that it doesn't work)

Sign in to reply to this post

lr_leal239405

This post has been deleted.

Ray BorduinWebAssist

What are the names of the columns in your database you want to search? Did you hand code this or use the interface?

It looks hand coded because you have form field names where you should have column names and the value area is blank.

The code should look something like:
$searchWADAss_templates_WADbSearch1->setSearch(array("type"=>"Key", "comparison"=>"=", "join"=>"AND", "and"=>", ", "or"=>" ", "start_encap"=>"\"", "end_encap"=>"\""), array("DBColumnName1", "DBColumnName2"), "s", "".((isset($_GET["ss_keywords"]))?$_GET["ss_keywords"]:"") ."");

Sign in to reply to this post

lr_leal239405

the columns names are ss_title and ss_keywords. I got code from interface then replaced the variable names with what I already had (also originally from interface). This is what was generated that was working originally:

<?php
$searchWADAss_templates_WADbSearch1 = new WA_MySQLi_Search("WADAss_templates","");
if (isset($_GET["Search"]) || isset($_GET["Search_x"])) {
$searchWADAss_templates_WADbSearch1->clearSearch();
$searchWADAss_templates_WADbSearch1->setSearch(array("type"=>"Edit", "comparison"=>"Includes", "join"=>"AND"), array("ss_title"), "s", "ss_title");
$searchWADAss_templates_WADbSearch1->setSearch(array("type"=>"Edit", "comparison"=>"Includes", "join"=>"AND"), array("ss_keywords"), "s", "ss_keywords");
}
?>

Then I just wanted to generate the code needed to get search to search thru both columns instead of using two search input fields separately. It originally generated this code thru that server behavior.

<?php
$searchRecordset2_1 = new WA_MySQLi_Search("Recordset2","0=0");
if (true) {
$searchRecordset2_1->clearSearch();
$searchRecordset2_1->setSearch(array("type"=>"Key", "comparison"=>"=", "join"=>"AND", "and"=>", ", "or"=>" ", "start_encap"=>"\"", "end_encap"=>"\""), array("ss_title", "ss_keywords"), "s", "");
}
?>

This was the original form before I took out Title field. I guess I need to change that?

<div id="Search_Basic_Default_ProgressWrapper">
<form class="Basic_Default" id="Search_Basic_Default" name="Search_Basic_Default" method="get" action="spec_sheets_results.php">
<fieldset class="Basic_Default" id="Search">
<legend class="groupHeader">Search</legend>

<div class="lineGroup">
<label for="ss_title" class="sublabel" >Title:</label>
<input id="ss_title" name="ss_title" type="text" value="<?php echo((isset($_GET["ss_title"])?$_GET["ss_title"]:"")); ?>" class="formTextfield_Medium" tabindex="4" title="Please enter a value.">
</div>
<div class="lineGroup">
<label for="ss_keywords" class="sublabel" >Keywords:</label>
<input id="ss_keywords" name="ss_keywords" type="text" value="<?php echo((isset($_GET["ss_keywords"])?$_GET["ss_keywords"]:"")); ?>" class="formTextfield_Medium" tabindex="5" title="Please enter a value.">
</div>


<span class="buttonFieldGroup" >
<input type="submit" value="Search" class="formButton unstyled" id="Search" name="Search" />
</span>
</fieldset>
</form></div>

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...