Viewing file: index.php (7.25 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
session_start();
if(session_is_registered("redirectURL")) header("Location:".$_SESSION["redirectURL"]."");
/** Define Validate Access */
define( '_VALID_ACCESS', 1 );
/** Configuration */
include_once("configuration.php");
require_once( $_Config_absolute_path . "/includes/framework.php" );
/** Create Database Object */
$dbObj = new DBConn;
/** Config Table for This Page */
$myTable = "formation_tb";
$myTableFK = "Code";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title><?=$_Config_sitename;?></title>
<script type="text/javascript" src="./js/utilities.js"></script>
<link href="./css/default.css" rel="stylesheet" type="text/css" />
</head>
<body topmargin="0" rightmargin="0" bottommargin="0" leftmargin="0">
<?php
include( "./templates/incHeader.php" );
?>
<table width="1003" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="215" align="left" valign="top" style="padding:10px 0px 0px 5px"><?php include( "templates/incMainMenuLeft.php" );?></td>
<td width="788" align="center" valign="top" style="padding:10px 0px 5px 10px">
<?php
/** Config Paging */
$limit = $_Config_limit;
$scroll = $_Config_scroll;
/** ตั้งค่า Default สำหรับการทำ Order By */
if( $OrderBy == "" ) { $OrderBy = $myTableFK; }
if( !isset($_GET['ASCDESC']) ) { $ASCDESC = "DESC"; }
if( $_GET['ASCDESC'] == "ASC" ) { $ASCDESC = "DESC"; }
elseif( $_GET['ASCDESC'] == "DESC" ) { $ASCDESC = "ASC"; }
/** Query เพื่อหา Numrows ก่อน */
$query = " SELECT * FROM $myTable ";
$result = $dbObj->execQuery($query);
$numrows = $dbObj->_numrows;
/** Paging */
$display = ( !isset ($_GET['page']) ) ? 1 : $_GET['page'];
$start = ( ($display * $limit) - $limit );
/** Paging */
if( isset($_GET['OrderBy']) ) {
$query = " SELECT * FROM $myTable ORDER BY $OrderBy $ASCDESC ";
}
elseif( !isset($_GET['OrderBy']) ) {
$query = " SELECT * FROM $myTable ORDER BY $myTableFK DESC ";
}
$query .= " LIMIT $start, $limit ";
$result = $dbObj->execQuery($query);
?>
<fieldset>
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="10"></td>
</tr>
<tr>
<td height="25" background="./images/background/bg-head-topic-w780.gif" class="NOTE PADDING-LEFT-10"> ข่าวประชาสัมพันธ์</td>
</tr>
</table>
<table width="97%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" valign="top"> </td>
</tr>
<?php
$no = 1+($display-1)*$limit;
while( $rs = $dbObj->fetchObject($result) ) {
$bgColor = ( $bgColor == "#FFFFFF" ) ? "#F9FBFB" : "#FFFFFF";
?>
<tr>
<td width="30" height="22" align="center" valign="top"><?=$no;?>.</td>
<td width="20" align="left"><img src="images/icons/doc-txt-blue-new.png" width="16" height="16" border="0" /></td>
<td width="703" valign="top" align="left"><a href="javascript:;" onclick="NewWindow('FormationDetail.php?Code=<?=$rs->Code;?>&Username=<?=$rs->Username;?>','FormationDetail','680','350','yes');"><?=$rs->InforName;?></a> <span style="color:#333333; font-size:10px"><?php if( $rs->date_updated != "" || $rs->date_updated != NULL ) echo "( ".$rs->date_updated ." )"; ?></span></td>
</tr>
<?php
$no++;
} # while
$dbObj->freeresult($result);
?>
<tr>
<td colspan="3" height="10"></td>
</tr>
</table>
<br />
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<?php if( $numrows > 0 ) { ?>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="10" colspan="2"></td>
</tr>
<tr>
<td width="84%" align="left"><span style="font-size:12px">หน้า:
<?php
/** ตรวจสอบการ Order By ของ Query */
if( $ASCDESC=="ASC") { $ASCDESC = "DESC"; } else { $ASCDESC="ASC"; }
$paging = ceil($numrows/$limit);
//if( $paging == 1 ) { echo "<font color=red size=2> [<strong>$paging</strong>] </font>"; }
if( $numrows==$_Config_limit ) {
echo "<font color=red size=2> [<strong>1</strong>] </font>";
}
//=== Display the navigation
if ($display > 1) {
$previous = $display - 1;
?><a href="<?=$PHP_SELF;?>?page=1"><font color="#FE830B">|« หน้าแรก</font></a> <a href="<?=$PHP_SELF;?>?page=<?=$previous;?>"><font color="#FE830B">« ก่อนหน้า</font></a>
<?php
} // end..if
if( $numrows != $limit ) {
if($paging > $scroll) {
$first = $_GET['page'];
$last = ($scroll - 1) + $_GET['page'];
} else {
$first = 1;
$last = $paging;
}
if($last > $paging ) {
$first = $paging - ($scroll - 1);
$last = $paging;
}
for($i=$first; $i<=$last; $i++) {
if( $display == $i ) {
echo "<font color=red size=2> [<strong>$i</strong>] </font>";
}
else {
//echo " <a href=\"$PHP_SELF?page=$i&user_id=$user_id&user_login=$user_login\">$i</a> ";
printf(" <a href=\"%s?page=%s\">%s</a> ", $_SERVER['PHP_SELF'], $i, $i);
}
} // end..for
} // end..if
if($display < $paging) {
$next = $display + 1;
?> <a href="<?=$PHP_SELF;?>?page=<?=$next;?>"><font color="#FE830B">ถัดไป »</font></a> <a href="<?=$PHP_SELF;?>?page=<?=$paging;?>"><font color="#FE830B">หน้าสุดท้าย »|</font></a><?php
} // end..if
?></span></td>
<td width="16%" align="right">ทั้งหมด: <strong><?=$numrows;?></strong> รายการ</td>
</tr>
</table>
<?php } #if ?></td>
</tr>
</table>
<br />
</fieldset></td>
</tr>
</table>
<?php include( "./templates/incFooter.php" ); ?>
</body>
</html>
<?php
/** Close the Database */
$dbObj->disconn();
/** Unset Class */
unset($dbObj);
?>
|