Component-specific how-tos (combo)
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 loadXML(url) method on client-side:
client-side:
var combo=new dhtmlXCombo("combo_zone2","alfa2",200); combo.loadXML("connector.php");
server-side:
<?php require_once("../codebase/connector/combo_connector.php"); $res=mysql_connect("localhost","root",""); mysql_select_db("mydb"); $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 a combo filters data by the “label” field.