Sample> Db Showrecords Advanced

<?php

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

$TPLN = new TPLN;
$TPLN->dbConnect();


// search treatment
$search '';
if(isset(
$_GET['search']) && !empty($_GET['search']))
{
    
$search $TPLN->xssProtect($_GET['search']); # xss protection
}


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

// dynamic query
$query 'SELECT * FROM Country';
if(!empty(
$search))
{

  
$search_protected $TPLN->checkQuotes($search);
  
$query .= " WHERE Name LIKE '$search_protected%' ";
  
$search urlencode($search);

  
$TPLN->urlAddVar("search=$search");// add search to url
}

$TPLN->setUrl('?'); // optional take current page by default
$TPLN->setNavColor('#FFFFFF','#FFFFC0'); // change colors of navigation
$TPLN->showRecords($query10); // only 10 results by page
$TPLN->dbClose();

$TPLN->write();




?>
<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" />
</head>
<body>

<form method="GET">
<fieldset>
    <legend>Search</legend>
    Country <input name="search" type="text" id="search" value="{$search}" />
    <br>
    <br>
    <input type="button" value="Reset" onClick="document.location.href='{$_SERVER['PHP_SELF']}';"  />
    <input type="submit" name="Submit" value="Send" />
</fieldset>
</form>


<bloc::data>
<table cellspacing="1" cellpadding="5">
<caption>Results {_First} to {_Last} of {_Count} (Page {_PageNumber} / {_PageCount})<caption>
<tr>
    <th colspan="3" align="center">
        <!-- Add previous bloc button -->
        <bloc::previous>
               <a href="{_Url}"><img src="../previous.gif" alt="Go previous page" align="absbottom"></a>
        </bloc::previous>
        <!--------------------------->

        <!-- Add pager bloc -->
        <bloc::pager>
               <bloc::out> <a href="{_Url}">{_Page}</a> </bloc::out>
               <bloc::in> <font color="red">{_Page}</font> </bloc::in>
        </bloc::pager>
        <!--------------------------->

        <!-- Add next bloc button -->
        <bloc::next>
               <a href="{_Url}"><img src="../next.gif" alt="Go next page" align="absbottom"></a>
        </bloc::next>
        <!--------------------------->
    </th>
</tr>

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

<tr>
    <th colspan="3" align="center">

        <!-- Add previous bloc button -->
        <bloc::previous>
               <a href="{_Url}"><img src="../previous.gif" alt="Go previous page" align="absbottom"></a>
        </bloc::previous>
        <!--------------------------->

        <!-- Add pager bloc -->
        <bloc::pager>
               <bloc::out><a href="{_Url}">{_Page}</a></bloc::out>
               <bloc::in><font color="red">{_Page}</font></bloc::in>
        </bloc::pager>
        <!--------------------------->

        <!-- Add next bloc button -->
        <bloc::next>
               <a href="{_Url}"><img src="../next.gif" alt="Go next page" align="absbottom"></a>
        </bloc::next>
        <!--------------------------->

    </th>
</tr>


</table>



<bloc::norecord>
<div id="norecord">
You have no record found for "<i>{$search}</i>"<br>
<br>
<a href="javascript:window.history.back()">Return to previous page</a>
</div>
</bloc::norecord>

</bloc::data>


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

</body>
</html>