phpLens
 home  products examples manual  faq support forum  contact news  login store

More Examples:   Run: Layout Template Demo

Free Download

<?php

error_reporting
(63);
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 "Layout Template Demo";
    include(
'./header.php');
    
if (!isset(
$HTTP_GET_VARS['orig']))
    print 
"Click <a href=ex304.php?orig=1>here</a> to see a grid that matches the original template <a href=print.php?f=orig&run=true>orig.tpl</a>.<br>";
else
    print 
"Click <a href=ex304.php>here</a> to see an alternate grid using template <a href=print.php?f=ex304&run=true>ex304.tpl</a>.<br>";
$lens PHPLensPConnect('ex304',"select * from lensusers order by userid",
        
'mysql',     // database server type, eg. pgsql, odbc, mssql, oci8
        
$gEX_server,    // eg. localhost or ODBC DSN
        
$gEX_userid,    
        
$gEX_password,    
        
$gEX_db2);    // optional, name of database to connect toif (! $lens) die('PHPLens ex300 failed to start');
//-----------------------------------------------------
// to disable dynamic editing, uncomment the line below
//$lens->dynEdit = 0;

error_reporting(63);
$lens->canEdit true;    // Show Edit Button
$lens->canNew true;    // Show New Record Button
$lens->canDelete true;    // Show Delete Button

$lens->keyTable 'lensusers';    // Save Data Table
$lens->keyCol 'USERID';    // Primary Key of Save Data Table
$lens->pageSize 10;    // rows per page

$lens->powerLens 'FirstName^{FirstName} {LastName}';
$lens->nameLens 
 
'AGE^Age;COUNTRY^Country^^^;CREATED^Created^^^;LASTMOD^LASTMOD^^^;PASSWORD^Password^^^;'
   
.'USERID^User ID^^^;FIRSTNAME^Name^First Name^First Name^First Name;LASTNAME^Last Name^^^;'
   
.'EMAIL^email^^^;ADDRESS1^Address Line 1^^^;ADDRESS2^Address Line 2^^^;POSTCODE^Postcode^^^;'
   
.'CITY^City^^^;STATE^State^^^';
$lens->gridLens 'USERID;FIRSTNAME;EMAIL';
$lens->detailLens 
  
'USERID;FIRSTNAME;LASTNAME;EMAIL;ADDRESS1;ADDRESS2;POSTCODE;CITY;STATE;COUNTRY;AGE;CREATED';
$lens->editLens 
  
'USERID;PASSWORD;FIRSTNAME;LASTNAME;EMAIL;ADDRESS1;ADDRESS2;POSTCODE;CITY;STATE;COUNTRY;AGE';
$lens->newLens 
  
'USERID;PASSWORD;FIRSTNAME;LASTNAME;EMAIL;ADDRESS1;ADDRESS2;POSTCODE;CITY;STATE;COUNTRY;AGE';
$lens->readOnlyLens 'CREATED';
$lens->defaultLens 'CREATED^=time();LASTMOD^=time()';
$lens->validation 'EMAIL^=email^';

$lens->mustFill 'USERID;PASSWORD';
if (isset(
$HTTP_GET_VARS['orig'])) $lens->templateLayout 'orig.tpl';
else 
$lens->templateLayout 'ex304.tpl';
$lens->columns =1;
//-----------------
// Generate HTML

$lens->Render();
$lens->Close();

?>

<h3>Notes</h3>
The layout templates are <a href=print.php?f=ex304&run=true>ex304.tpl</a> and
  <a href=print.php?f=orig&run=true>orig.tpl</a>.
<?php        
include ('./footer.php');
?>
email: contact#phplens.com (change # to @)     telephone (malaysia): 60-3-7947 2888     fax (malaysia): 60-3-7947 2800