close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

search - replace spaces in search with commas

Thread began 7/15/2013 11:16 am by mrs | Last modified 7/16/2013 8:48 am by mrs | 1157 views | 5 replies

mrs

search - replace spaces in search with commas

I need to reduce search results returned, and I am going to have more than one repeated list of search results due to three different recordsets for three different tables in my DB.

I need to replace spaces with commas, but my code isn't working for some reason. By that I mean if I type 'test', I get 93 results. If I type 'test sweden', I still get 93 results... what ever I type, I get 93 results!

This is my replace code:

<?php
// line added to insert commas before spaces which are inputted by the user during searches
if(isset($_GET["searchbox"])) $_GET["searchbox"] = str_replace(" ", ", ", $_GET["searchbox"]);
?>


This is one of the WA search codes:

<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: rs_eventslist;
//Searchpage: search-results.php;
//Form: searchform;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ((isset($_POST["WADbSearch1"])) && ($_POST["WADbSearch1"] != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations
$KeyArr0 = array("fld_eventNAME", "fld_eventLOCATION", "fld_eventINTRO", "fld_eventDETAIL", "fld_eventVENUE", "fld_eventMAPTITLE", "fld_eventMAPADDRESS", "fld_eventMAPDESCRIPTION", "fld_eventEMAIL", "fld_eventURL");

//comparison list additions
$WADbSearch1->keywordComparison($KeyArr0,"".((isset($_POST["searchbox"]))?$_POST["searchbox"]:"") ."","AND","Includes",",%20","%20","%22","%22",0);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_searchresults"]=$WADbSearch1->whereClause;
}
}
else {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//get the filter definition from a session variable
if (1 == 1) {
if (isset($_SESSION["WADbSearch1_searchresults"]) && $_SESSION["WADbSearch1_searchresults"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_searchresults"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
?>



This is my search form code:

<form action="search-results.php" id="searchform" name="searchform" method="get">
<input name="searchbox" type="text" id="searchbox" placeholder="Search...">
<input type="image" src="../images/search-trans.png" width="26px" height="26px" border="0" alt="GO" name="button" id="button" value="Button">
</form>

Am I not meant to be using the 'searchbox' to replace the spaces with commas?

Thanks.

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