3.0 beta 2

display data from database into a Grid

How to display data from database(SQL- Server ) in the Grid?
Mohan
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
<?php 
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);
  for($i=0;$i<$nr;$i++){
    $row = mysql_fetch_array($result, MYSQL_NUM);
    for($j=0;$j<$nf;$j++){
      echo $row[$j] . "\t";
    }
    echo "\n";
  } 
}
?>



And you call it with your grid

var table = new AW.CSV.Table;
  table.setURL("data.php");
  table.request();
..........


simple example without using XML. hopes this helps

David Gutierrez
December 23,
Can I display data from DB2 database?
Emman
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.
Tony
December 28,
How do I assign this table to a grid, in version 2.0?
Andrew
January 3,
Can u plz tell me why this error comes up:
"AW" is undefined
BDC
January 5,
show your code and we can help
David Gutierrez
January 5,
I am getting an error:"AW is undefined"

My code:

<html>
<head>
<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>


<style>

.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;
}
</style>
</head>
<body>
<!--load data from db-->
<script>


var table = new AW.CSV.Table;
table.setURL("data.php");


table.request();

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

document.write(obj);
</script>

</body>
</html>
January 6,
how to define query able data grid of using javascript and xml
susi
June 29,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.