|
<?php ob_start(); include('/big/dom/xphplens/www/php/phplens/phplens.inc.php'); session_start();
//---------------------------------------- // The following lines are for formatting // the page and not needed by phplens $gTitle = "Advanced Filtering"; include('./header.php'); ?> <p> This uses a filter template to reformat the search form vertically. The phpLens search form is very flexible. Try the following: <p> <table align=center cellpadding=2 border=1><tr><td> - Search for all product id's greater than 30: <td> <b>>30</b> <tr><td> - All product id's between 10 to 30: <td> <b>10 (to) 30</b> <tr><td> - All product names beginning with V: <td> <b>V</b> </table> </ul> </p>
<?php $lens = PHPLensPConnect('ex311',"select * from products order by 1", 'mysql', // database server type, eg. pgsql, odbc, mssql, oci8 $gEX_server, // eg. localhost or ODBC DSN $gEX_userid, $gEX_password, $gEX_db); // optional, name of database to connect to
if (! $lens) die('PHPLens ex311 failed to start');
$lens->firstState = 'FILTERVIEW'; $lens->lookupLens = 'CATEGORYID^select categoryid,categoryname from categories;SUPPLIERID^select supplierid,substring(companyname,1,20) from suppliers;QUANTITYPERUNIT^select distinct quantityperunit from products';
$lens->exportLens = 'PRODUCTID;PRODUCTNAME;SUPPLIERID;CATEGORYID;QUANTITYPERUNIT';
$lens->colorNav = '#c0c0c0'; $lens->colorNavBorder = '#e0e0e0'; $lens->colorSelect = 'yellow';
$lens->lang->topCaption = '<b><font color=white> </font></b>'; $lens->lang->bottomCaption = ' '; $lens->nameLens = 'CATEGORYID^Category^^^^^;SUPPLIERID^Supplier^^^^^;QUANTITYPERUNIT^Qty/Unit^^^^^';
$lens->layoutTableHeader = 'align="center" border="0" cellspacing="0" cellpadding="1" width="100%" '; $lens->gridTableHeader = 'width="100%" border="1" cellspacing="1" cellpadding="1" '; $lens->detailTableHeader = 'width="100%" border="1" cellspacing="0" cellpadding="2" ';
$lens->keyTable = 'PRODUCTS'; // Save Data Table $lens->keyCol = 'PRODUCTID'; // Primary Key of Save Data Table $lens->pageSize = 50; // rows per page $lens->showRecNo = 0; // 0=hide 1=left 2=right $lens->templateFilter = 'ex311.tpl';
$lens->filterParams = 'SUPPLIERID^^^2';
//----------------- // Generate HTML
$lens->Render(); $lens->Close();
?>
<h3>Notes</h3>
This example demonstrates using a template to change the search screen: <pre> $lens->templateFilter = 'ex311.tpl'; </pre> <p> The contents of the template: <p> <code>
{$<b>_FORMBEGIN_</b>}<br> <table width="100%" border="1"><br> <tr bgcolor="#333333"><br> <td colspan=5 align=right><font color="#FFFFFF"><br> {$<b>_SUBMIT_</b>}</font> {$<b>_DYNEDIT_</b>} &nbsp; </td><br> </tr><br> <tr bgcolor="#666666"><br> <td><b><font color="#FFFFFF">{$<b>PRODUCTID_T</b>}</font></b></td><br> <td><b><font color="#FFFFFF">{$<b>PRODUCTNAME_T</b>} </font></b></td><br> <td><b><font color="#FFFFFF">{$<b>SUPPLIERID_T</b>}</font></b></td><br> <td><b><font color="#FFFFFF">{$<b>CATEGORYID_T</b>}</font></b></td><br> <td><b><font color="#FFFFFF">{$<b>QUANTITYPERUNIT_T</b>}</font></b></td><br> </tr><br> <tr><br> <td>{$<b>PRODUCTID</b>}</td><br> <td>{$<b>PRODUCTNAME</b>}</td><br> <td>{$<b>SUPPLIERID</b>}</td><br> <td>{$<b>CATEGORYID</b>}</td><br> <td>{$<b>QUANTITYPERUNIT</b>}<br> </td><br> </tr><br> </table><br> {$<b>_FORMEND_</b>}<br> </p> </code> <p> The template consists of the fields ,eg {$PRODUCTID}, and the captions {$PRODUCTID_T}. And we also have the buttons {$_SUBMIT_} and {$_CANCEL_}, though the cancel button has been removed. The {$_DYNEDIT_} tag holds the green "e" editor button. Finally we have the form management tags {$_FORMBEGIN_} and {$_FORMEND_}. <p> Other features include exporting to Excel [which requires the ob_start() call at the beginning of the page)] and setting the firstState to FILTERVIEW, so the search screen appears on startup. <pre> $lens->exportLens = 'PRODUCTID;PRODUCTNAME;SUPPLIERID;CATEGORYID;QUANTITYPERUNIT'; $lens->firstState = 'FILTERVIEW'; </pre> <?php include ('./footer.php'); ?>
|
|