Combobox

I am creating a form integrated with a database table and it’s working with this code:



z2.enableFilteringMode(true);     

z2.loadXML(“autosuggestxmllist.php?op=softwarexml&pos=0&mask=TEXT”, true, true);





I want to make it work when a user inputs just parts of the name, for instance, if the name is

“AIWA image special 2.0”, I want to enable to find it even if a user input just like

“image special”.



softwarexml is now written in PHP and goes like this:



function softwarexml($input, $cat, $cat2, $cat3)

{

$sqltext2 = “”;

    

if (trim($input) != ‘’)

    {

        $input = explode(" “, $input);

    

        $i = 0;

        

     while ($i < count($input))

     {

            if ($i > 0)

            {

                $sqltext2 .= “AND(SoftwareName LIKE ‘%$input[$i]%’)”;

            }

            else

            {

                $sqltext2 .= “(SoftwareName LIKE ‘%$input[$i]%’)”;        

            }

            $i++;

        }

        $sqltext2 = “AND (”.$sqltext2.”)";

    }

    



    $query = "    SELECT     ID, SoftwareName

                FROM     Softwares

                WHERE     (RecordStatusID = 0) $sqltext2

                ORDER BY ID";    



$results = mssql_query($query);

header(“Content-Type: text/xml”);

echo “<?xml version=\"1.0\" encoding=\"utf-8\" ?>”;

    

    while(list($uid, $softwarename) = mssql_fetch_row($results))

    {

        $softwarename = trim(htmlspecialchars($softwarename));

        echo “<option value=”$uid">$softwarename";

    }

    echo

    “”;

}



It doesn’t work. Do you have any suggestions?

As far as I can understood you are using combo just for data presentation and use custom inputs to define filtering criteria, right?
So the problem is not related to component - it will show any data loaded from server side.

The problem may be in your server side code, which currently uses the AND for all searching clauses and most probably need to use OR between different filtering options.


$sqltext2 .= “OR (SoftwareName LIKE ‘%$input[$i]%’)”;

$sqltext2 = “AND ( 1=2 OR “.$sqltext2.”)”;
}



$query = " SELECT ID, SoftwareName
FROM Softwares
WHERE (RecordStatusID = 0) $sqltext2
ORDER BY ID";

Thank you for the reply. It works brilliantly.
I am making a php interface for someone to search for database value, and input & edit data from the page.

By the way, I would like to make the combo box both fully loaded and filtering.
So when the page loaded I want to show data from a table, and when the user input data searches for the value.

So I put both of lines on the page like this, the filtering mode works, but it doesn’t display data when it’s loaded.

Do you have any suggestions?

            var z2=new dhtmlXCombo(“softwareidcon”,“softwareid”,300);        
            z2.enableFilteringMode(true, “autosuggestxmllist.php?op=softwarexml&mask=TEXT”, true, true);
        //    z2.enableFilteringMode(true);    
            z2.loadXML(“autosuggestxmllist.php?op=softwarexml&pos=0&mask=TEXT”, true, true);

but it doesn’t display data when it’s loaded.
When filtering mode enabled grid will not show any value for empty input

dhtmlxcombo.js, line 960

dhtmlXCombo.prototype._fetchOptions=function(ind,text){
if (text=="") { this.closeAll(); return this.clearAll(); }


You can try to modify it as

dhtmlXCombo.prototype._fetchOptions=function(ind,text){
if (text=="") return;