RE: [PEAR] question about Structures_DataGrid

From: Date: Tue, 15 May 2007 11:16:53 +0000
Subject: RE: [PEAR] question about Structures_DataGrid
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-27295@lists.php.net to get a copy of this message
This isn't exactly what you asked for, but this is a working example of how to take data from a db using MDB2 pear library and have Structures_DataGrid turn it into a sortable table with page numbers <?php $dsn = array( 'phptype' => 'mysql', 'username' => DB_DEV_USER, 'password' => DB_DEV_PASS, 'hostspec' => DB_DEV_HOST, 'database' => DB_DEV_NAME, ); $db =& MDB2::connect($dsn); if (PEAR::isError($db)) { die($db->getMessage()); } $db->setFetchMode(MDB2_FETCHMODE_ASSOC); $db->loadModule('Extended'); // 2 records per page $datagrid =& new Structures_DataGrid(2); // Setup your datasource $test = $datagrid->bind("SELECT * FROM tbllessons", array( 'dbc' => $db )); if (PEAR::isError($test)) { echo $test->getMessage(); } // Print the DataGrid with the default renderer (HTML Table) $html = $datagrid->getOutput(); $html .= $datagrid->getOutput(DATAGRID_RENDER_PAGER); echo $html; ?> -----Original Message----- From: Anton Tobolchenko [mailto:tobolchenko@gmail.com] Sent: Tuesday, May 15, 2007 2:00 PM To: pear-general@lists.php.net Subject: [PEAR] question about Structures_DataGrid Hi, I am a web programmer from Russia. First of all, excuse my bad english =) I have a question about *Structures_DataGrid* class. I read documentation on http://pear.php.net/manual/en/package.structures.structures-datagrid.php#pac kage.structures.structures-datagrid.structures-datagrid-datasource but i didn't understand how it work. Please, help me.I think that i will understand all, if i saw a correctly code. For example, lets take such task: create table with 2 columns and 3 rows. First - checkboxes and secont - simple static text (not edit). In the beginning we have array with data. And table we need to build on that array (take from array information about which checkbox is checked and what is the static text will be near it). Which php code will generate such table if we a using pear *Structures_DataGrid* class? Please, write all code from "<?php" till "?>". I hope you will understand my problem and will help me.

« previous php.pear.general (#27295) next »