Here's an example of how you can get this to work. (It's probably worth copying this code into a code editor so that you can see it clearly.)
First of all the PHP file:
?php
include_once '../vLIB/vlibTemplate.php';
$tmpl = new vlibTemplate'./news.tmpl;
$cnx = mysql_connect 'localhost', ***, ***
mysql_select_db'released_test', $cnx;
$sql1 = 'SELECT code,description FROM table1'; // get the categories
$result1 = mysql_query $sql1, $cnx;
$tmpl-newLoop'NEWS'; // name of outer loop
while $row1 = mysql_fetch_assoc$result1
//inner loop
$sql2 = "SELECT page, headline,story FROM table2 WHERE page= ". $row1code.";
$result2 = mysql_query$sql2, $cnx;
$innerloop = array;
while $row2 = mysql_fetch_assoc$result2
$innerloop = array'page'=$row2'page','headline'=$row2'headline','story'=$row2'story';
// Add row WITH inner loop to vlibTemplate
$row_to_add = array
'code'=$row1'code', // from table 1
'description'=$row1'description', // from table 1
'stories' = $innerloop // from table 2 innerloop is called stories
;
$tmpl-addRow$row_to_add, 'NEWS';
$tmpl-addLoop'NEWS';
$tmpl-pparse;
?
.. and a very simple template will look like:
html
body
tmpl_loop name=NEWS
tmpl_var name=descriptionbr /
------------------------------br /
tmpl_loop name=stories
btmpl_var name=headline/b - tmpl_var name=storybr /
/tmpl_loop
br /br /
/tmpl_loop
/body
/html
I hope this helps! If not then let me know!
Kind regards,
Kelvin