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). This demo also uses Column tags.
| 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 2</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). This demo also uses <code>Column</code> tags.</p>
<hr />
<php:datagrid name="demo" width="100%" AutoGenerateColumns="false" cellpadding="5" cellspacing="0" border="true">
<Style font-family="Verdana" background-color="#eeeeee" font-size="12px" />
<HeaderStyle Background-Color="#000" bold="true" text-color="#fff" />
<AlternateItemStyle background-color="#fff" />
<Column datafield="id" HeaderText="ID" />
<Column datafield="title" HeaderText="Title" />
<Column datafield="category" HeaderText="Category" />
<Column datafield="author" HeaderText="Author" />
</php:datagrid>
<hr />
<h2>Source:</h2>
<div style="background-color: #EFEFEF;"><?php highlight_file(__FILE__); ?></div>
</body>
</html>