DataView (loading data from multiple tables)

Hi,

I have data for car model, car image, and car url spread in 3 different tables. Currently, i can use dataview to load car model from “tbl_carmodel” and display it. However, i am not sure how to use the data connector to get data from 3 seperate tables so that i can use it in dataview.

Database Tables
tbl_carmodel => id, carmodel
tbl_carimage => id, carmodel, imagelocation
tbl_carurl => id, carmodel, url

Expected Output
Please see attached file.

I have the current code so far:

data = new dhtmlXDataView({
    container:"data_container",
    type:{
	template: #carmodel#,
	height:40
    }
});

data.load("php/load_dataview.php")
	   
var dp = new dataProcessor("php/load_dataview.php");
dp.init(data);

PHP File (load_dataview.php)

[code]<?php
session_start();
include(“connect.php”);
$conn = mysql_connect(“$host”,“$username”,“$password”)or die(“cannot connect”);
if (!$conn) {
die('Could not connect: ’ . mysql_error());
}
mysql_select_db(“$db_name”,$conn) or die(“cannot select DB”);

require("../codebase/connector/dataview_connector.php");
$data = new DataViewConnector($conn);
$data->render_table("tbl_carmodel","id","carmodel");
mysql_close($conn);

?>[/code]

Thanks


Hi,

You may use render_sql method instead of render_table. In this case, you can use own sql query which will allow to get data from several tables:

docs.dhtmlx.com/doku.php?id=dhtm … operations