PHP Classes

File: examples/tbs_us_examples_dyncol.php

Recommend this page to a friend!
  Classes of Skrol29   TinyButStrong template engine   examples/tbs_us_examples_dyncol.php   Download  
File: examples/tbs_us_examples_dyncol.php
Role: Example script
Content type: text/plain
Description: examples and tests - dynamic columns
Class: TinyButStrong template engine
Template Engine for Pro and Beginners
Author: By
Last change: goes with last TBS version
Date: 5 years ago
Size: 842 bytes
 

Contents

Class file image Download
<?php

include_once('tbs_class.php');

$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('tbs_us_examples_dyncol0.htm');

// Retreiving user data
if (!isset($_GET)) $_GET =& $HTTP_GET_VARS;
$nbr_row = (isset($_REQUEST['nbr_row'])) ? intval($_REQUEST['nbr_row']) : 10;
$nbr_col = (isset($_REQUEST['nbr_col'])) ? intval($_REQUEST['nbr_col']) : 10;

// List of column's names
$columns = array();
for (
$col=1 ; $col <= $nbr_col ; $col++) {
   
$columns[$col] = 'column_' . $col;
}

// Creating data
$data = array();
for (
$row=1 ; $row<=$nbr_row ; $row++) {
   
$record = array();
    for (
$col=1 ; $col <= $nbr_col ; $col++) {
       
$record[$columns[$col]] = $row * $col;
    }
   
$data[$row] = $record;
}

// Expanding columns
$TBS->MergeBlock('c0,c1,c2',$columns);

// Merging rows
$TBS->MergeBlock('r',$data);
$TBS->Show();

?>