<?php
// include TPLN
include('TPLN/TPLN.php');
$TPLN = new TPLN;
$TPLN->open('Db_multiple_query.html');
$TPLN->dbConnect();
$TPLN->doQuery('SELECT Code, Name FROM Country ORDER BY RAND() LIMIT 10');
$qID = $TPLN->getQueryID(); // strore index resultset
while($row = $TPLN->dbFetch())
{
$TPLN->parse('Country.Name', $row['Name']);
// retrive different languages
$sql = "SELECT Language FROM CountryLanguage WHERE CountryCode = '{$row['Code']}'";
$TPLN->doQuery($sql);
while($row2 = $TPLN->dbFetch())
{
$TPLN->parse('Country.Language.Name', $row2['Language']);
$TPLN->loop('Country.Language');
}
$TPLN->loop('Country');
$TPLN->setQueryID($qID); // retrieve the first result set
}
$TPLN->dbClose();
$TPLN->write();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Db multiple query result</title>
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<bloc::Country>
<h1>{Name}</h1>
<ul>
<bloc::Language>
<li>{Name}</li>
</bloc::Language>
</ul>
</bloc::Country>
<br>
<br>
{_Logo}<font size="1"> in {_Chrono} s<br>
Queries executed: {_QueryCount}</font>
</body>
</html>