Sample> Advanced Cache

<?php

// include TPLN
include('TPLN/TPLN.php');

$TPLN = new TPLN;

// every five minutes file cached is created
if(!isset($_GET['nb']))$_GET['nb'] = 0;
$_GET['nb'] = (int)$_GET['nb'];

// dynamic cache evey 30 seconds
if(!$TPLN->open("advanced_cache.html?nb={$_GET['nb']}",'CACHED'30))
{
    echo 
"<span style=\"color:red; font-weight:bold;\">
          Create cached file <em>'advanced_cache.html?nb=
{$_GET['nb']}'</em>
          </span>"
;

    
$TPLN->parse('time',date('H:i:s'));

    
// connectio and query are used only to recreate a new template !
    
$TPLN->dbConnect();

    
$TPLN->doQuery("SELECT * FROM Country LIMIT {$_GET['nb']}, 10");
    
$TPLN->parseDbRow('loop');

    
$TPLN->dbClose();
}

$TPLN->write();


?>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>TPLN - Advanced Cache</title>
    <link href="../style.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <h1>The cache is created every 30 seconds and it is dynamic !</h1>

    <ul>
        <li>Display All <a href="advanced_cache.php?nb=0">advanced_cache.php?nb=0</a></li>
        <li>Display result > 5 <a href="advanced_cache.php?nb=5">advanced_cache.php?nb=5</a></li>
        <li>Display result > 10 <a href="advanced_cache.php?nb=10">advanced_cache.php?nb=10</a></li>
    </ul>

    <table cellpadding="3" cellspacing="1">
    <caption>Time of creation {time}</caption>
    <tr>
        <th>Code</th>
        <th>Name</th>
        <th>Chief</th>
    </tr>

    <bloc::loop>
    <tr bgcolor="{_NavColor}">
        <td>{Code}</td>
        <td>{Name}</td>
        <td>{HeadOfState}</td>
    </tr>
    </bloc::loop>

    </table>


    <br>
    <br>
    {_Logo}<font size="1"> in {_Chrono} s<br>
    Queries executed: {_QueryCount}</font>


</body>
</html>