Sample> Db Showrecords Ajax

<?php

// configuration ******************************************************
if(!isset($_GET['ajax']) || $_GET['ajax'] != 1)
    
$_GET['ajax'] = 0;
//***********************************************************************

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


$TPLN = new TPLN;

$TPLN->open('Db_showrecords_ajax.html');

$TPLN->dbConnect();
$TPLN->setUrl('?'); // optional take current page by default
$TPLN->showRecords('SELECT * FROM Country'10); // only 10 results by page
$TPLN->dbClose();


if(!
$_GET['ajax'])
{
    
$TPLN->write();
}
else
{
    
sleep(1); // remove this line, it is just to show ajax in action
    
header('Content-Type: text/html; charset=utf-8');
    echo 
$TPLN->getAjaxBloc('content');
}



?>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>TPLN - DB function ShowResult Sample</title>
    <link href="../style.css" rel="stylesheet" type="text/css" />
    <script language="javascript" src="ajax.js"></script>
</head>

<body>

<div id="loader">Loading...please wait...</div>

<div id="content">
<!-- ajax::content -->


<bloc::data>
<table cellpadding="3" cellspacing="1">
<caption>Results {_First} to {_Last} of {_Count}</caption>
<tr>
    <th>Code</th>
    <th>Name</th>
    <th>Chief</th>
</tr>

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

<tr>
    <th colspan="3">
        <bloc::previous>
            <a href="javascript:goto('{_Url}');"><img src="../previous.gif" align="absmiddle" /></a>
        </bloc::previous>

        Page {_PageNumber} / {_PageCount}

        <bloc::next>
            <a href="javascript:goto('{_Url}');"><img src="../next.gif" align="absmiddle" /></a>
        </bloc::next>
    </th>
</tr>

</table>



    <bloc::norecord>You have no record found</bloc::norecord>
</bloc::data>

<!-- /ajax::content -->
</div>

</body>
</html>