This demo shows how to bind the results of a database query to a PHP:Datagrid using formatting properties and style information (specifically a HeaderStyle and AlternateItemStyle).
| id | title | category | author |
|---|---|---|---|
| 1 | Item 1 | 3 | Dennis |
| 2 | Item 2 | 5 | John |
| 3 | Item 3 | 2 | Chris |
| 4 | Item 4 | 3 | Jeremy |
| 5 | Item 5 | 6 | Chris |
| 6 | Item 6 | 5 | John |
| 7 | Item 7 | 3 | Dennis |
| 8 | Item 8 | 7 | Chris |
| 9 | Item 9 | 8 | Dennis |
| 10 | Item 10 | 3 | Jeremy |
| 11 | Item 11 | 9 | Dennis |
| 12 | Item 12 | 3 | John |
| 13 | Item 13 | 2 | Chris |
| 14 | Item 14 | 1 | Dennis |
| 15 | Item 15 | 5 | John |
| 16 | Item 16 | 3 | Jeremy |
<?php
include ('phpdatagrid.php');
// Include Sample data
include ('sampledata.php');
// Bind data to datagrid
$_DATAGRID->bind ('demo', $data);
?>
<html>
<head>
<title>PHP:DataGrid - Demo 1</title>
</head>
<body>
<h1>Simple PHP:DataGrid Demo</h1>
<p>This demo shows how to bind the results of a database query to a
PHP:Datagrid using formatting properties and style information
(specifically a HeaderStyle and AlternateItemStyle).</p>
<hr />
<php:datagrid name="demo" width="100%"
Style-Font-Size="12px;"
cellpadding="5" Style-Font-Family="Verdana" cellspacing="0"
border="true" Style-Background-Color="#eeeeee"
AlternateItemStyle-Background-Color="#ffffff" HeaderStyle-bold="true"
HeaderStyle-Background-Color="#000" HeaderStyle-Text-Color="#fff" />
<hr />
<h2>Source:</h2>
<div style="background-color: #EFEFEF;"><?php highlight_file(__FILE__); ?></div>
</body>
</html>