Browse database records

From: Date: Sun, 28 Oct 2001 15:59:31 +0000
Subject: Browse database records
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-2426@lists.php.net to get a copy of this message
Jean-Michel POURE schrieb: > Looks great, thanks. What about integrating > http://www.dominion.org.mx/ > (browsing) with HTML_OOH_FORM (editing)? > I am new to PEAR. Is there already a solution for database records > browsing? Is anyone working on this issue? I'm working on something like that. It's in alpha state so I haven't published it yet (if someone's interested I'd like to contribute it). It's based on the DB and IntegratedTemplate classes and works (or should work ;-)) like that: $stmt = new IFW_DBSelectGenerator(); $stmt->addField("*"); $stmt->addTable("user"); $stmt->addFilter("username LIKE 'a%'"); $stmt->addSort("username"); $grid = new IFW_DBGrid(TEMPLATE_PATH, "userlist.tpl", $stmt); $grid->setPageSize(10); $grid->show(); Page handling and sorting is done automatically. There are special variables you can integrate in the template (ROWNO, ROWCOUNT, ROWMIN, ROWMAX, <fieldname>, URL_SORT_<fieldname>, ...). Here's a template example: Rows {ROWMIN}-{ROWMAX} from {ROWCOUNT}, page {PAGENO} from {PAGENOMAX} <table border=1 cellpadding=0 cellspacing=0 borderwidth=0 bgcolor=#aaaaaa> <tr><td> <table border=0 cellpadding=0 cellspacing=3 borderwidth=0> <tr> <td rowspan=2> <table border=1 bgcolor=#ffffff width=400> <tr bgcolor=#dddddd> <th>&nbsp;</th> <th><a href="{URL_SORT_USERNAME}">Name</a></th> <th><a href="{URL_SORT_SURNAME}">Full Name</a></th> <th>Department</th> <th>Location</th> </tr> <!-- BEGIN listrow --> <tr> <td>{ROWNO}</td> <td><a href="{URL_BASE}?module=user&action=edit&userid={USERID}">{USERNAME}</a></td> <td>{PRENAME} {SURNAME}</td> <td>{ORGUNITNAME}</td> <td>{LOCATIONNAME}</td> </tr> <!-- END listrow --> </table> </td> <td valign=top> <!-- BEGIN prevpage --> <a href="{URL_PREVPAGE}">[&lt;&lt;]</a> <!-- END prevpage --> </td> </tr> <tr> <td valign=bottom> <!-- BEGIN nextpage --> <a href="{URL_NEXTPAGE}">[&gt;&gt;]</a> <!-- END nextpage --> </td> </tr> </table> </td></tr> </table> Guido -- Guido Schoepp, gusmail@gmx.net

« previous php.pear.dev (#2426) next »