|
|
ShowRecords function
void ShowRecords(string query, int result_by_page=0) |
The ShowRecords() function is a function that permits to parse
the data coming automatically from your database,
you only have to create your template and the function takes care of all for you!
Your template must be to configure as this:
- <bloc::data>
- <bloc::loop></bloc::loop> contains the name of your fields in variable
- <bloc::norecord></bloc::norecord> contains the message if there are not any results li>
- </bloc::data>
This function possesses its variable owners who are automatically here parsées
those must be present in the block <bloc::data></bloc::data>
they are noted like this {_Variable}.
- _First indicates the position of the
first record li>
- _Last indicates the position of the
last record li>
- _Count indicates the number of results
li>
- _PageNumber indicates the present page
li>
- _PageCount indicates the number of total
page li>
Variable owners between <bloc::loop></bloc::loop>
- _Id indicates the number of registration
generated by TPLN
- _NavColor replaces by one two colors
specified in the TPLN_Cfg.php file or by SetNavColor()
TPLN generates for you nagigation buttons (pagination included), you have to
define its inside your bloc <bloc::data>
as blocs, they are customizables:
- Pager to create results pagination,
this bloc must countains 2 blocs, <bloc::in>
and<bloc::out>
- <bloc::in> is generated for the
actual page of results, this bloc must countains the variable {_Page}
- <bloc::out> is generated for the
others pages of results, this bloc must countains the variable {_Page}
et {_Url}.
<bloc::pager>
<bloc::in><font color="red">{_Page}</font></bloc::in>
<bloc::out><a href="{_Url}">{_Page}</a></bloc::out>
</bloc::pager>
|
- Start to go at the first page of results,
this bloc must countains the variable {_Url}
<bloc::start>
<a href="{_Url}"><img src="bng.gif" border=0></a>
</bloc::start>
|
- Previous to go at the previous page
of results, this bloc must countains the variable{_Url}
<bloc::previous>
<a href="{_Url}"><img src="prev.gif" border=0></a>
</bloc::previous>
|
- Next to go at the next page of results,
this bloc must countains the variable {_Url}
<bloc::next>
<a href="{_Url}"><img src="suiv.gif" border=0></a>
</bloc::next>
|
- End to go at the last page of results,
this bloc must countains the variable {_Url}
<bloc::end>
<a href="{_Url}"><img src="suiv.gif" border=0></a>
</bloc::end>
|
|
<?php
include("TPLN/TPLN.php");
$TPLN = new TPLN;
$TPLN->Open("template.html");
$query = "SELECT * FROM my_table";
$TPLN->DbConnect();
$TPLN->ShowRecords($query,10); // 10 results by page
$TPLN->DbClose();
$TPLN->Write();
?>
|
Attention ! |
Since TPLN 1.5, this function has changed his pagination concept. |
|