What would you think of this solution.
[!-- BBCode Start --][TABLE BORDER=0 ALIGN=CENTER WIDTH=85%][TR][TD][size=8]Code:[/size]
[/TD][/TR][TR][TD]
<?php
include_once "../vlibTemplate.php";
$tmpl = new vlibTemplate('./test.html');
$q = "select username, firstname, lastname from users";
$cnx = mysql_connect('localhost', 'user', 'password');
$result = mysql_db_query('vlibdb', $q);
// this is the new stuff
$tmpl->newLoop('myloop'); // tells us the name of the new loop
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$tmpl->addRow($row); // this would add a row to the previously named loop
}
$tmpl->pparse();
?>
[/TD][/TR][TR][TD]
[/TD][/TR][/TABLE][!-- BBCode End --]
So this is an idea of how one could pass in a single dimensional array to a loop, making it easier to understand and program. The array could be an associative array like this:
[!-- BBCode Start --][TABLE BORDER=0 ALIGN=CENTER WIDTH=85%][TR][TD][size=8]Code:[/size]
[/TD][/TR][TR][TD]
array(
'username' => 'pj',
'firstname' => 'Peter',
'lastname' => 'Johnson'
);
[/TD][/TR][TR][TD]
[/TD][/TR][/TABLE][!-- BBCode End --]
Nested loops would be to complicated using this structure, but then they're an advanced feature anyway.
Tell me what you think!
Kelvin