3.0 beta 2

display data from database into a Grid

How to display data from database(SQL- Server ) in the Grid?
June 25,
I suppose you could pass in a function that returns the data in xml format.
December 22,
simple way using php

php code for a data.php file
function db_connect() { 
  $database_name = 'xxxxxxx'; // Set this to your Database Name 
  $database_username = 'xxxxxxx'; // Set this to your MySQL username 
  $database_password = 'xxxxxxx'; // Set this to your MySQL password 
  $result = mysql_pconnect('localhost',$database_username, $database_password); 
  if (!$result) return false; 
  if (!mysql_select_db($database_name)) return false; 
  return $result; 

$conn = db_connect(); // Connect to database 

$query = "select * from GUEST";

if ($conn) { 
  $result = mysql_query($query,$conn);
  $nf = mysql_num_fields($result);
  $nr = mysql_num_rows($result);
    $row = mysql_fetch_array($result, MYSQL_NUM);
      echo $row[$j] . "\t";
    echo "\n";

And you call it with your grid

var table = new AW.CSV.Table;

simple example without using XML. hopes this helps

David Gutierrez
December 23,
Can I display data from DB2 database?
December 28,
yes, just use the apropriate php code ( which I do not know sence I never used that ibm product with php before)
David Gutierrez
December 28,
For the record, you can use ANY database.
Run your query and format the returned data into format suitable for AW.
The data can be formatted into XML,CSV,TAB, or even JS code.
December 28,
How do I assign this table to a grid, in version 2.0?
January 3,
Can u plz tell me why this error comes up:
"AW" is undefined
January 5,
show your code and we can help
David Gutierrez
January 5,
I am getting an error:"AW is undefined"

My code:

<title>ActiveWidgets Grid :: Examples</title>
<style> body, html {font: menu; background: threedface;} </style>

<!-- ActiveWidgets stylesheet and scripts -->
<link href="../../runtime/styles/classic/grid.css" rel="stylesheet" type="text/css" ></link>
<link href="../../runtime/styles/classic/aw.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/grid.js"></script>


.active-controls-grid {height: 100%; font: menu;}

.active-column-0 {width: 80px;}
.active-column-1 {width: 200px; background-color: threedlightshadow;}
.active-column-2 {text-align: right;}
.active-column-3 {text-align: right;}
.active-column-4 {text-align: right;}

.active-grid-column {border-right: 1px solid threedshadow;}
.active-grid-row {border-bottom: 1px solid threedlightshadow;}
.active-templates-input {
overflow: hidden;
width: 100%;
height: 100%;
padding: 0px 5px;
margin: -1px 0px;
border: 1px solid #666;
vertical-align: middle;
font: menu;
line-height: 1.4em;

.active-templates-input.gecko {
display: block;
margin: 0px;
<!--load data from db-->

var table = new AW.CSV.Table;


var obj = new Active.Controls.Grid;
obj.setProperty("column/count", 5);
obj.setModel("data", table);


January 6,
how to define query able data grid of using javascript and xml
June 29,

This topic is archived.

See also:

Back to support forum


Version 2

Looking for AW 2.6 ?
The old site is here.