Page 1 of 1

Minimum number of characters in search form

Posted: Sun May 04, 2008 4:19 pm
by joebarker99
I'd like to edit this search page so that the search form requires a minimum number of characters. Can someone help me out or give me a code that I can add to this? Thanks.


Code: Select all

 
<?
$lUseAjax=1;
$pagename=LA_SEARCH;
include_once("header_inc.php");
 
$searchpage=1;
$catid_search = getParamInt("catid_search","");
$lDoNotCreateTemplate=1;
$tplList=new TplLoad;
if (getParam("reset",""))
    redirect("search.php");
 
$lSearchWordTpl=getParam("searchword","");
 
$tplList->assign("set_region","$set_region");
$tplList->assign("searchword",$lSearchWordTpl);
$tplList->assign("catlist",getCategoriesDD(getParamInt("catid_search",""),""));
$tplList->assign("set_currency_text","$set_currency_text");
$lExtraAdd="";
        
// Check if we have a category id to search in
if($catid_search>0)
{
    if (!$_REQUEST["catid_search"]=="%%")
    {
        $result_1 = q ("select cat_tpl from $cat_tbl where cat_id = ".round($_REQUEST["catid_search"]));
        $rad=mysql_fetch_array($result_1);
        $cattpl_cat = $rad["cat_tpl"];
    }
}
        
$result_1 = q ("select cat_tpl from $cat_tbl where cat_id = '$catid_search'");
$row_cat = mysql_fetch_array($result_1);
$cat_tpl = $row_cat["cat_tpl"];
 
/* Extra fields handling START */
$lFieldArray=getExtraFiltered($cat_tpl,"","",$set_language);
 
 
if (is_array($lFieldArray))
{
    foreach ($lFieldArray as $lKey => $lValue)
    { 
        if ($lValue["q_question"])
            $lFieldArray[$lKey]["q_question"]=(constant($lValue["q_question"]));
        if ($lValue["q_catdescr"])
            $lFieldArray[$lKey]["q_catdescr"]=(constant($lValue["q_catdescr"]));
    }
}
 
$lJoinedInputArray=array_merge($_POST,$_GET);
 
/* Special code to fix so that intervals (from-to) can be performed */
foreach ($lJoinedInputArray as $key => $value) {
    //echo "$key - $value<br>";
    if (ereg("from",$key))
    {
        $key=ereg_replace("e_","",$key);
        $key=ereg_replace("_from","",$key);
        $lFieldArray["$key"]["q_value_from"]=$value;
    }
    elseif (ereg("to",$key))
    {
        $key=ereg_replace("e_","",$key);
        $key=ereg_replace("_to","",$key);
        $lFieldArray["$key"]["q_value_to"]=$value;
    
    }
}
$tplList->assign("extra_fields_array",$lFieldArray); // Add question to template
 
if (is_array($lFieldArray))
{
    $lReturnResultArray=ExtraFieldsInputOperations($lFieldArray);
    $lInsertArray=$lReturnResultArray[0];   // Contains data to be inserted to extra
    $errorMsg=$lReturnResultArray[1];       // Contains error messages
}
/* Extra fields handling FINISH */
 
 
if (count($lLevelArray)==3)
{
    $lReg3Selected=$lLevelArray[1]["reg_id"];
    $lReg3Father=$lLevelArray[1]["reg_father"] . "_";
    
    $lReg2Selected=$lLevelArray[2]["reg_id"];
    $lReg2Father=$lLevelArray[2]["reg_father"];
    
    $lReg1Selected=$lLevelArray[3]["reg_id"];
    
    
}
else if (count($lLevelArray)==2) 
{
    $lReg2Selected=$lLevelArray[1]["reg_id"];
    $lReg2Father=$lLevelArray[1]["reg_father"];
 
}
    
 
 
$lReg2Father=getParam("reg_1",$lReg2Father);
$lReg2Selected=getParam("reg_2",$lReg2Selected);
 
if ($lReg2Father && $lReg2Selected!="")
    $lReg2String=$lReg2Father . "|" . $lReg2Selected;
else 
    $lReg2String=$lReg2Father;
 
$lReg3Father=getParam("reg_2",$lReg3Father);
$lReg3Selected=getParam("reg_3",$lReg3Selected);
 
 
if ($lReg3Father && $lReg3Selected!="")
    $lReg3String=$lReg3Father . "|" . $lReg3Selected;
else 
    $lReg3String=$lReg3Father;
 
$tplList->assign("reg_2_value",$lReg2String);
$tplList->assign("reg_3_value",$lReg3String);
 
 
$tplList->assign("options",getRegionTree(0,0,$lSelected));
$lRegOptions="<option value=''>".LA_REGION_CHOOSE_FIRST."</option>";
$lRegOptions.=getRegionsForOneLevel(0,getParam("reg_1",$lReg1Selected),"");
$tplList->assign("reg_1_options",$lRegOptions);
 
 
if (getParam("do_search","") || getParam("searchword","")!="")
    require("links.php");
else
{ 
    $tplList->assign("hide",1);
    $tplList->display("search_links.tpl");
}
include_once("footer_inc.php");
?>
 

Re: Minimum number of characters in search form

Posted: Sun May 04, 2008 4:55 pm
by John Cartwright
Take a look at the strlen() function

Re: Minimum number of characters in search form

Posted: Sun May 04, 2008 10:25 pm
by joebarker99
Take a look at the strlen() function

Hmmmm, I'm very new to this stuff. Could someone please use the code I posted above to create a code that I can add to this search.php page that will require a minimum number of characters to submit a search? Thanks.

Re: Minimum number of characters in search form

Posted: Sun May 04, 2008 11:50 pm
by John Cartwright
joebarker99 wrote:
Take a look at the strlen() function

Hmmmm, I'm very new to this stuff. Could someone please use the code I posted above to create a code that I can add to this search.php page that will require a minimum number of characters to submit a search? Thanks.
Sorry, our objective is not to do the work for you. What have you tried?