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.