Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Open Source PHP version of ASP.NET DataGrid or GridView?

95 views
Skip to first unread message

wrburgess

unread,
Feb 13, 2008, 3:32:24 PM2/13/08
to
I am trying to find a PHP control, framework, or application that has
a behavior equivalent to the ASP.NET DataGrid or GridView controls.
Other terms I've seen are "HTML Table", "Table View", or "Database
Grid."

I know you can hand-code a database query that prints out an HTML
table, but I'm looking for a re-suable control that can consume a DB
query and return HTML-compliant tabled data.

I'm aiming for something in the open source realm, if possible. Any
suggestions are appreciated.

C. (http://symcbean.blogspot.com/)

unread,
Feb 14, 2008, 7:45:46 AM2/14/08
to

phplens is probably the most complete/usable solution I've come across

C.

Betikci Boris

unread,
Feb 14, 2008, 6:41:55 PM2/14/08
to

$connection = @mysql_connect('localhost', 'user', 'password');
@mysql_select_db('database', $connection);
$query = 'SELECT * FROM myTable LIMIT 0,10';
$dataset = @mysql_query($query, $connection);


// print MySQL query results as 2D javascript array
function aw_cells($dataset){

$rows = array();
while ($record = @mysql_fetch_row($dataset)) {
$cols = array();
foreach ($record as $value) {
$cols[] = '"'.addslashes($value).'"';
}
$rows[] = "\t[".implode(",", $cols)."]";
}
echo "[\n".implode(",\n",$rows)."\n];\n";
}

// print MySQL field names as javascript array
function aw_headers($dataset){
while ($field = @mysql_fetch_field($dataset)) {
$cols[] = '"'.$field->name.'"';
}
echo "[".implode(",",$cols)."];\n";
}

?>
<html>
<head>
<!-- include AW stylesheet and script -->
<link href="../../runtime/styles/system/aw.css" rel="stylesheet"
type="text/css" ></link>
<script src="../../runtime/lib/aw.js"></script>
</head>
<body>
<script>

// insert javascript arrays produced by PHP functions
var myHeaders = <?= aw_headers($dataset) ?>
var myCells = <?= aw_cells($dataset) ?>

// create grid control
var obj = new AW.UI.Grid;

// set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);

// set number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);

// write grid to the page
document.write(obj);

</script>
</body>
</html>

Betikci Boris

unread,
Feb 14, 2008, 6:46:46 PM2/14/08
to

i will post the aw.js

Betikci Boris

unread,
Feb 14, 2008, 6:50:09 PM2/14/08
to
On Feb 15, 1:41 am, Betikci Boris <pard...@gmail.com> wrote:

I can't put the aw.js here but you can go http://www.activewidgets.com/
to see the datagrid script examples in there.

Ali Bobo

unread,
Feb 14, 2008, 8:57:45 PM2/14/08
to

Not sure if it will suit you, but TYPO3 currently supports MySQL,
Oracle, Microsoft SQL Server, Sybase, Sybase SQL Anywhere, DB2,
Informix, PostgreSQL, FrontBase, Interbase (Firebird and Borland
variants), Foxpro, Access, ADO, SAP DB, SQLite and ODBC.

http://typo3.com/Feature_list.1243.0.html

Jerry Stuckle

unread,
Feb 14, 2008, 10:28:54 PM2/14/08
to

What - no DBASE III support? :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

wrburgess

unread,
Feb 15, 2008, 1:06:21 PM2/15/08
to
Thanks for the replies!
0 new messages