Check documentation for the latest version 6.0 of dhtmlxSuite Combo Specific HowTos DHTMLX Docs

Combo Specific HowTos

How can I populate combo with data from db?

To define options of combo you should use ComboConnector on the server side and specify the connector file in the load method on the client side:

client side:

var combo=new dhtmlXCombo("combo_zone2","alfa2",200);
combo.load("connector.php");

server side:

<?php 
require_once("../codebase/connector/combo_connector.php");
$res=new PDO("mysql:dbname=mydb;host=localhost","root","");
 
$data = new ComboConnector($res, "MySQL");
$data->render_table("categories","id","valueColumn, labelColumn");
?>
  • Names of the fields can have aliases (value or label) to identify the appropriate attribute.
$data->render_sql(
    "SELECT *, CONCAT(FirstName, LastName) as label FROM table1",
    "id",
    "id,FirstName(label)"
);

Note, in the filtering mode Combo filters data by the "label" field.

Back to top