Location: PHPKode > scripts > MyTemplate Class > mytemplate-class/index-Example.php
<?php

// ãáÝ ÇáÅÚÏÇÏÇÊ
 include "inc/config.php";

// ãáÝ ÇáÊÑæíÓÉ
 include "templates/$theme/header.html";

// Öãä ÇáãÊÕÝÍ ÝÇÚÊÈÑå ÑÞã ÇáÕÝÍÉ $_GET['page'] ÅÐÇ Êã ÊÚÑíÝ
if(isset($_GET['page']))
{
    $pageNum = $_GET['page'];
}

// ÍÓÇÈ ÇáÓÌáÇÊ Ýí ßá ÕÝÍÉ
$offset = ($pageNum - 1) * $rowsPerPage;

######################################################################
//  ÇÓÊÎáÇÕ ÇáÈíÇäÇÊ ãä ÇáÞÇÚÏÉ
$query  = "SELECT * FROM `myTable` LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query 1 failed');

// ÇÓÊÏÚÇÁ ÏÇáÉ ÇáÞæÇáÈ
include("inc/MyTemplate.class");

// ÊÚÑíÝ ÇáÞÇáÈ
$myhtml = MyTemplate::MyTemplate("templates/$theme/DataTable.html");

// ÚÑÖ ãÍÊæíÇÊ ÓÌáÇÊ ÞÇÚÏÉ ÇáÈíÇäÇÊ
while($row = mysql_fetch_array($result))
    {
    //echo "<ooo>" .$row['id']. " - <font color=red>" .$row['name']. "</font></ooo><br>";

    $id = $row['id'];
    $name = $row['name'];
    $email = $row['email'];
    $comments = $row['comments'];
    $website = $row['website'];

    //  ÇÓÊÈÏÇá ÇáãÊÛíÑÇÊ ÇáãæÌæÏÉ Ýí ÇáÞÇáÈ ÈÞíãåÇ ãä ÞÇÚÏÉ ÇáÈíÇäÇÊ
    eval ("print stripslashes(\"$myhtml\");");
    }
######################################################################

//  ÈÜÜÜÏÁ ÚÑÖ ÃÑÞÇã ÇáÕÝÍÇÊ
print '<br>';
print '<center>';

// ÅÌãÇáí ÚÏÏ ÇáÓÌáÇÊ Ýí ÞÇÚÏÉ ÇáÈíÇäÇÊ
$query   = "SELECT COUNT(id) AS numrows FROM `myTable` ";
$result  = mysql_query($query) or die('Error, query 2 failed1');
$row     = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];

// ÅÌãÇáí ÚÏÏ ÇáÕÝÍÇÊ
$maxPage = ceil($numrows/$rowsPerPage);

// ÅäÔÇÁ ÑÇÈØ áßá ÑÞã ÕÝÍÉ
$self = $_SERVER['PHP_SELF'];
$nav = '';
for($page = 1; $page <= $maxPage; $page++)
{
       if ($page == $pageNum)
       {
           $nav .= " $page ";  // ÚÑÖ ÑÞã ÇáÕÝÍÉ ÇáÍÇáíÉ ÈÏæä ÑÇÈØ
       }
       else
       {
           $nav .= " <a href=\"$self?page=$page\" style=\"text-decoration: none\">[$page]</a> ";
       }
}

// ÅäÔÇÁ ÑÇÈØ ÇáÕÝÍÉ ÇáÊÇáíÉ æÇáÓÇÈÞÉ
// æÅäÔÇÁ ÑÇÈØ áÐåÇÈ ãÈÇÔÑÉ ááÕÝÍÉ ÇáÃæáì Ãæ ÇáÃÎíÑÉ

if ($pageNum > 1)
{
    $page = $pageNum - 1;
    $prev = " <a href=\"$self?page=$page\" style=\"text-decoration: none\">[ÇáÕÝÍÉ ÇáÓÇÈÞÉ]</a> ";

    $first = " <a href=\"$self?page=1\" style=\"text-decoration: none\">[ÇáÕÝÍÉ ÇáÃæáì]</a> ";
}
else
{
    $prev  = '&nbsp;'; // äÍä Ýí ÇáÕÝÍÉ ÇáÃæáì ÝáÇ ÊÖÚ ÑÇÈØ ÇáÕÝÍÉ ÇáÓÇÈÞÉ
    $first = '&nbsp;'; // æáÇ ÑÇÈØ ÇáÕÝÍÉ ÇáÃæáì ßÐáß
}

if ($pageNum < $maxPage)
{
    $page = $pageNum + 1;
    $next = " <a href=\"$self?page=$page\" style=\"text-decoration: none\">[ÇáÕÝÍÉ ÇáÊÇáíÉ]</a> ";

    $last = " <a href=\"$self?page=$maxPage\" style=\"text-decoration: none\">[ÇáÕÝÍÉ ÇáÃÎíÑÉ]</a> ";
}
else
{
    $next = '&nbsp;'; // äÍä Ýí ÇáÕÝÍÉ ÇáÃÎíÑÉ ÝáÇ ÊÖÚ ÑÇÈØ ÇáÕÝÍÉ ÇáÊÇáíÉ
    $last = '&nbsp;'; // æáÇ ÑÇÈØ ÇáÕÝÍÉ ÇáÃÎíÑÉ ßÐáß
}

// ÈÏÇíÉ ÚÑÖ ÑæÇÈØ ÇÓÊÚÑÇÖ ÇáÕÝÍÇÊ
print "<div class='num'>";

if ($DisplayFirst=="äÚã") print $first;
if ($DisplayPrevious=="äÚã") print $prev;
if ($DisplayNumbers=="äÚã") print $nav;
if ($DisplayNext=="äÚã") print $next;
if ($DisplayLast=="äÚã") print $last;

if ($DisplayTotalPages=="äÚã") print "<BR><BR>" . $TotalPagesText . "<font color=Green>" . $maxPage . "</font></div>";
print "</center>";


// ÅÛáÇÞ ÇáÇÊÕÇá ÈÞÇÚÏÉ ÇáÈíÇäÇÊ
// MySQL Server ÇÎÊíÇÑí .. áßäå ãÓÊÍÓä áÊæÝíÑ ãæÇÑÏ
mysql_close($conn);

?>

</body>
</html>
Return current item: MyTemplate Class