Source code of tbs_us_examples_dyncol1.php

  1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
<?php

include_once('../tbs_class.php');

$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('tbs_us_examples_dyncol1.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=$col <= $nbr_col $col++) {
    
$columns[$col] = 'column_' $col;
}

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

// Expanding columns
$TBS->MergeBlock('c',$columns);

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