hye to all and gud day.. i'm stuck with this page and yet i couldnt find any solution on my advanced search page.
In this page, i have a lot of search criterias which includes text fields, comboboxes and list boxes. Keywords searched thru Text fields and comboboxes (logically with one option selected) gave the right results BUT, the list boxes where user can select multiple options gave me nothing, no result (i wonder why the sql query doesnt work at all??)..
can anybody please... help me in solving this problem? it has made me stuck for weeks~~~
These codes are in my Advance Search Page:
// Get action
$sAction = @$HTTP_POST_VARS["a_search"];
switch ($sAction)
{
case "S": // Get Search Criteria
// Build search string for advanced search, remove blank field
$sSrchStr = "";
// Field ReligionName
$x_ReligionName = @$HTTP_POST_VARS["x_ReligionName"];
$z_ReligionName = (get_magic_quotes_gpc()) ? stripslashes(@$HTTP_POST_VARS["z_ReligionName"][0]) : @$HTTP_POST_VARS["z_ReligionName"][0];
if ($x_ReligionName <> "") {
$sSrchFld = $x_ReligionName;
$sSrchWrk = "x_ReligionName=" . urlencode($sSrchFld);
$sSrchWrk .= "&z_ReligionName=" . urlencode($z_ReligionName);
} else {
$sSrchWrk = "";
}
if ($sSrchWrk <> "") {
if ($sSrchStr == "") {
$sSrchStr = $sSrchWrk;
} else {
$sSrchStr .= "&" . $sSrchWrk;
}
}
if ($sSrchStr <> "") {
ob_end_clean();
header("Location: ViewSearchResultCus.php" . "?" . $sSrchStr);
exit();
}
}
While these codes are in my result list page:
// Open connection to the database
$conn = phpmkr_db_connect(HOST, USER, PASS,DB);
// Handle Reset Command
ResetCmd();
// Get Search Criteria for Advanced Search
SetUpAdvancedSearch();
// Build Search Criteria
if ($sSrchAdvanced != "") {
$sSrchWhere = $sSrchAdvanced; // Advanced Search
}
elseif ($sSrchBasic != "") {
$sSrchWhere = $sSrchBasic; // Basic Search
}
// Save Search Criteria
if ($sSrchWhere != "") {
$HTTP_SESSION_VARS["ViewSearchResult_searchwhere"] = $sSrchWhere;
// Reset start record counter (new search)
$nStartRec = 1;
$HTTP_SESSION_VARS["ViewSearchResult_REC"] = $nStartRec;
}
else
{
$sSrchWhere = @$HTTP_SESSION_VARS["ViewSearchResult_searchwhere"];
}
// Build WHERE condition
$sDbWhere = "";
if ($sDbWhereMaster != "") {
$sDbWhere .= "(" . $sDbWhereMaster . ") AND ";
}
if ($sSrchWhere != "") {
$sDbWhere .= "(" . $sSrchWhere . ") AND ";
}
if (strlen($sDbWhere) > 5) {
$sDbWhere = substr($sDbWhere, 0, strlen($sDbWhere)-5); // Trim rightmost AND
}
//-------------------------------------------------------------------------------
// Function SetUpAdvancedSearch
// - Set up Advanced Search parameter based on querystring parameters from Advanced Search Page
// - Variables setup: sSrchAdvanced
function SetUpAdvancedSearch()
{
global $HTTP_GET_VARS;
global $sSrchAdvanced;
// Field ReligionName
$x_ReligionName = (get_magic_quotes_gpc()) ? stripslashes(@$HTTP_GET_VARS["x_ReligionName"]) : @$HTTP_GET_VARS["x_ReligionName"];
$arrFldOpr = "";
$z_ReligionName = (get_magic_quotes_gpc()) ? stripslashes(@$HTTP_GET_VARS["z_ReligionName"]) : @$HTTP_GET_VARS["z_ReligionName"];
$arrFldOpr = split(",",$z_ReligionName);
if ($x_ReligionName <> "") {
$sSrchAdvanced .= "customer.ReligionName "; // Add field
$sSrchAdvanced .= @$arrFldOpr[0] . " "; // Add operator
if (count($arrFldOpr) >= 1) {
$sSrchAdvanced .= @$arrFldOpr[1]; // Add search prefix
}
$sSrchAdvanced .= (!get_magic_quotes_gpc()) ? addslashes($x_ReligionName) : $x_ReligionName; // Add input parameter
if (count($arrFldOpr) >=2) {
$sSrchAdvanced .= @$arrFldOpr[2]; // Add search suffix
}
$sSrchAdvanced .= " AND ";
}
}
I just pasted few lines of codes that i think is relevant. Overview of my Advance page is: I have a listbox of Religion Name, where user can select few options which SHUD give results accordingly BUT apparently it's not.
If any one wants to see the full code, do tell me.. I really appreciate if anybody could give me any advice on this.. Thank you a lot in advance..
:glare: tired wif codes already~ videxx