PClib demo site

<?php
/* project: Search grid, file: searchgrid.php */

/* We want remember sorting and filtering. It will be stored in session. */
session_start();

//Include pclib framework
require 'pclib/pclib.php';

//Create pclib application
$app = new PCApp('demo');

$datasource 'pdo_mysql://user:password@localhost/test';

$app->db = new PCDb($datasource);

/* Template parameters are remembered in sessform & sessprod session variables */
$searchForm = new PCForm("tpl/searchform.tpl""sessform");
$products = new PCGrid ("tpl/products.tpl""sessprod");

if (
$searchForm->submitted) {
  
$products->filter $searchForm->values;
  if (
$app->action == 'showall') {
    
$products->filter $searchForm->values null;
    
$searchForm->deleteSession();
  }
}

/* Parameters in square brackets are replaced with values from grid->filter array.
   If value in grid->filter is empty, line of the query is omitted. */
$products->setQuery(
  
"select * from PRODUCTS where 1
  ~ and productLine = '{productLine}'
  ~ and productName like '{productName}%'
  ~ and productCode like '{productCode}%'"
  
);


if (isset(
$_GET['export'])) {
  
$products->exportExcel('products.csv');
}



print 
$searchForm;
print 
$products;

?>

Elapsed time: 372.88 ms