|
<?php 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 = "Live Demo - Charting UnitsInStock"; include('./header.php'); ?> <font size=2> The following example displays a list of products, with bar charts of units in stock. <p><ul> <li>The red <img src="/php/phplens/img/editbtn.gif" width="14" height="13"> <a href="/lens/lensman/tablesettings.htm">Edit phpLens Settings</a> icon to configure phpLens globally. <li>The gray <img src="/php/phplens/img/editcol.gif" width="14" height="13"> <a href="/lens/lensman/columnsettings.htm">Edit Column Settings</a> icons set column formating, charting (for numeric data), and cell colors. <li> The two green <img src="/php/phplens/img/edittab.gif" width="14" height="13"> <a href="/lens/lensman/visiblecolumns.htm">Edit Visible Columns</a> icons determine what columns are visible for the Grid and Details tables.</font></ul> <?php //---------------------------------------------------- // setup lens and render it with persistent connection $lens = PHPLensPConnect ( 'ex180', // id to uniquely identify this phplens setup "select * from products", '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) { // chart UnitsInStock $lens->chartLens = 'UNITSINSTOCK'; $lens->chartParams = 'UNITSINSTOCK^150^12^SV^0^200^blue.gif^red.gif^1^';
// SUBTOTAL BY STOCK $lens->sumLens = 'UnitsInStock'; //------------------ // GROUP BY CATEGORY $lens->groupLens = 'categoryid'; $lens->pageSize = 10; //------------------------------------------------------------- // map categoryid to categoryname and supplierid to companyname $lens->lookupLens = 'CATEGORYID^select categoryid,categoryname from categories;' .'SUPPLIERID^select supplierid,companyname from suppliers'; //---------------------------------- // choose columns to display in grid $lens->gridLens = 'PRODUCTNAME;SUPPLIERID;QUANTITYPERUNIT;UNITSINSTOCK;UNITPRICE'; //-------------------- // shorten grid titles $lens->nameLens = 'CATEGORYID^Category;SUPPLIERID^Supplier;UNITSINSTOCK^Stock;' .'UNITPRICE^Price;PRODUCTNAME^Product;QuantityPerUnit^Qty/Unit'; $lens->Render(); $lens->Close(); } ?> <h4>Notes</h4> We did it in a couple of minutes by generating it with the <a href=/lens/lensman/gridbuilder.htm>Grid Builder</a> and then configuring it in our Web browser. <p>
The charting is configured in Column Settings: <a href=ex180.php?lens_e_ex180=col&lens_p1=6> <img border=0 src=<?php echo $PHPLENS_PATH; ?>/img/editcol.gif>Stocks</a>. Then we Generated PHP Code, and pasted the code (<i>chartLens</i> and <i>chartParams</i> properties) into ex180.php.
<?php include ('./footer.php');
?>
|
|