By: clasen
Date: 2005-10-14
Time: 08:03
|
dynamic table
I have this script
((test.php))
<?php
include_once('tbs_class_php5.php'); // motor de templates
$table[] = array('nombre'=>'martín','apellido'=>'clasen');
$table[] = array('nombre'=>'Louisa','apellido'=>'Lane');
$tbs = new clsTinyButStrong ;
$tbs->LoadTemplate('test.html') ;
$tbs->MergeBlock('th',current($table));
$tbs->show();
?>
|
((test.html))
<html>
<table>
<tr>
<th>[th.key;block=th]</th>
</tr>
<tr>
<td>[???????]</td>
</tr>
</table>
</html>
|
I need to show()
<tr>
<th>nombre</th><th>apellido</th>
</tr>
<tr>
<td>martín</td><td>clasen</td>
</tr>
<tr>
<td>Louisa</td><td>Lane</td>
</tr>
|
The structure of the array could be different
ie.
array(array('name','surname'),array('martin','clasen'),array('louisa','lane'))
tnx!
|
By: Skrol29
Date: 2005-10-14
Time: 17:55
|
Re: dynamic table
Hello,
I'm not sure to understand your problem.
Could you give more details ?
|
By: neverpanic
Date: 2005-10-14
Time: 21:14
|
Re: dynamic table
Have a look at the last example, you need two nested $tbs->MergeBlocks.
|
By: clasen
Date: 2005-10-14
Time: 22:35
|
Re: dynamic table
tnx for all. I solve my problem using the dynamic table example.
tbs_us_examples_dyncol.php
<?php
include_once('tbs_class.php') ;
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('tbs_us_examples_dyncol.htm') ;
$table = array(
array('nombre'=>'martín','apellido'=>'clasen','other'=>'pete'),
array('nombre'=>'dsa','apellido'=>'dsadsa')
);
$columns = array_keys(current($table));
// Expanding columns
$TBS->MergeBlock('c0,c1,c2',$columns) ;
// Merging rows
$TBS->MergeBlock('r',$table) ;
$TBS->Show() ;
?> |
tbs_us_examples_dyncol.htm
<table border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>X</td>
<th>[c0.val;block=th]</th>
</tr>
<tr>
<td>[r.$;block=tr]</td>
<td>[r.[c1.val;block=td];noerr]</td>
</tr>
<tr>
<td>[r.$;block=tr]</td>
<td>[r.[c2.val;block=td];noerr]</td>
</tr>
</table>
|
$tbs->show();
<table border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>X</td>
<th>nombre</th><th>apellido</th><th>other</th>
</tr>
<tr>
<td>0</td>
<td>martín</td><td>clasen</td><td>pete</td>
</tr><tr>
<td>1</td>
<td>dsa</td><td>dsadsa</td><td></td>
</tr>
</table>
|
|
|
Posting in progress.
Please wait...
|