?? fileadmin.php
字號:
<?php
ob_start();
session_start();
if ($_SESSION['flag']!=1)
{
die("<div align=center>請先<a href=login.php><font color=blue>-- 登錄 --</font></a></div>");
}
//沒頁顯示記錄數
$PageSize = 7;
$StartRow = 0; //開始顯示記錄的編號
//獲取需要顯示的頁數,由用戶提交
if(empty($_GET['PageNo'])){ //如果為空,則表示第1頁
if($StartRow == 0){
$PageNo = $StartRow + 1; //設定為1
}
}else{
$PageNo = $_GET['PageNo']; //獲得用戶提交的頁數
$StartRow = ($PageNo - 1) * $PageSize; //獲得開始顯示的記錄編號
}
//因為顯示頁碼的數量是動態變化的
//假如總共有一百頁,則不可能同時顯示100個鏈接
//而是根據當前的頁數顯示一定數量的頁面鏈接
//設置顯示頁碼的初始值
if($PageNo % $PageSize == 0){
$CounterStart = $PageNo - ($PageSize - 1);
}else{
$CounterStart = $PageNo - ($PageNo % $PageSize) + 1;
}
//顯示頁碼的最大值
$CounterEnd = $CounterStart + ($PageSize - 1);
?>
<!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=gb2312" />
<title>文章管理</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<?php
include 'conn.php';
$TRecord = mysql_query("SELECT * FROM file");
$result = mysql_query("SELECT fileid,filename,filetype,filedate,fileuser FROM file ORDER BY fileid LIMIT $StartRow,$PageSize");
//獲取總記錄數
$RecordCount = mysql_num_rows($TRecord);
//獲取總頁數
$MaxPage = $RecordCount % $PageSize;
if($RecordCount % $PageSize == 0){
$MaxPage = $RecordCount / $PageSize;
}else{
$MaxPage = ceil($RecordCount / $PageSize);
}
?>
<body>
<div align="center">
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="150" colspan="2">
<img src="image/houtaihead.gif" longdesc="image/houtaihead.gif" /></td>
</tr>
<tr>
<td height="25" colspan="2" align="center"><font size="-1" color="blue"><?php echo date("20y年m月d日");?></font></td>
</tr>
<tr>
<td width="160" height="14"></td>
<td width="620" rowspan="2" align="left">
<form action="filesearch.php" method="post" name="form1">
<br>
<table width="620" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse" >
<tr>
<td colspan="4" align="center"><font size="+2" color="#FF9966"><b>文章管理</b></font></td>
</tr>
<tr>
<td width="120" height="31" align="center"><font size="-1">搜索文章:</font></td>
<td width="172" align="center"><input name="text1" type="text" onFocus="this.value=''" value="請輸入搜索內容!" size="20" maxlength="50" /></td>
<td width="89">
<select name="option">
<option value="kong" selected>-- 類型 --</option>
<option value="公告">公告</option>
<option value="it資源">it資源</option>
<option value="新聞動態">新聞動態</option>
<option value="認證信息">認證信息</option>
<option value="資料下載">資料下載</option>
</select> </td>
<td width="119" align="center"><input name="button2" type="submit" id="button2" value="搜 索..."></td>
</tr>
<tr>
<td height="243" colspan="4" valign="top">
<table width="100%" border="0" class="NormalTableTwo">
<tr>
<td colspan="2" class="AttachedFiles" align="center">
<font color="#FF9999"><?php print "總共".$RecordCount."條記錄 - 當前頁: $PageNo/$MaxPage" ?></font></td>
</tr>
</table>
<table width="100%" border="1" bordercolor="#FFCC99" cellspacing="3" cellpadding="2">
<tr>
<td width="9%" align="center" class="MandatoryFields">編號</td>
<td width="33%" align="center" class="MandatoryFields">標題</td>
<td width="16%" align="center" class="MandatoryFields">類型</td>
<td width="12%" align="center" class="MandatoryFields">發布人</td>
<td width="10%" align="center" class="MandatoryFields">發布時間</td>
<td width="10%" align="center" class="MandatoryFields">修改</td>
<td width="10%" align="center" class="MandatoryFields">刪除</td>
</tr>
<?php
$i = 1;
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$bil = $i + ($PageNo-1)*$PageSize;
?>
<tr>
<td class="NormalTable" align="center"><?php echo $row[0] ?></td>
<td class="NormalTable" align="center"><?php echo $row[2] ?>
<script language="JavaScript">
function Confirmer<?php echo $i;?>()
{
if (confirm("確定要刪除(<?php echo $row[2] ?>),以及與此相關的所有內容!"))
{
window.location.href='del_file.php?id=<?php echo $row[0];?>';
}
}
</script>
</td>
<td class="NormalTable" align="center"><?php echo $row[1] ?></td>
<td class="NormalTable" align="center"><?php echo $row[4] ?></td>
<td class="NormalTable" align="center"><?php echo $row[3] ?></td>
<td class="NormalTable" align="center"><a href=changefile.php?id=<?php echo $row[0];?>>修改</a></td>
<td class="NormalTable" align="center"><a href="#" onClick='Confirmer<?php echo $i;?>()'>刪除</a></td>
</tr>
<?php
$i++;
}?>
</table>
<table width="100%" border="1" bordercolor="#FFCC99" height="20">
<tr>
<td height="15">
<div align="center">
<?php
echo "<font size=-1>";
//顯示第一頁或者前一頁的鏈接
//如果當前頁不是第1頁,則顯示第一頁和前一頁的鏈接
if($PageNo != 1){
$PrevStart = $PageNo - 1;
print "<a href=fileadmin.php?PageNo=1>第一頁</a>: ";
//print "<a href=fileadmin.php?PageNo=$PrevStart>Previous </a>";
}
print " [ ";
$c = 0;
//打印需要顯示的頁碼
for($c=$CounterStart;$c<=$CounterEnd;$c++){
if($c < $MaxPage){
if($c == $PageNo){
if($c % $PageSize == 0){
print "$c ";
}else{
print "$c ,";
}
}elseif($c % $PageSize == 0){
echo "<a href=fileadmin.php?PageNo=$c>$c</a> ";
}else{
echo "<a href=fileadmin.php?PageNo=$c>$c</a> ,";
}//END IF
}else{
if($PageNo == $MaxPage){
print "$c ";
break;
}else{
echo "<a href=fileadmin.php?PageNo=$c>$c</a> ";
break;
}//END IF
}//END IF
}//NEXT
echo "] ";
if($PageNo < $MaxPage){ //如果當前頁不是最后一頁,則顯示下一頁鏈接
$NextPage = $PageNo + 1;
echo "<a href=fileadmin.php?PageNo=$NextPage>下一頁</a>";
}
//同時如果當前頁補上最后一頁,要顯示最有一頁的鏈接
if($PageNo < $MaxPage){
$LastRec = $RecordCount % $PageSize;
if($LastRec == 0){
$LastStartRecord = $RecordCount - $PageSize;
}
else{
$LastStartRecord = $RecordCount - $LastRec;
}
print " : ";
echo "<a href=fileadmin.php?PageNo=$MaxPage>最后一頁</a>";
}
echo "</font>";
?>
</div> </td>
</tr>
</table> <?php
mysql_free_result($result);
mysql_free_result($TRecord);
?> </td>
</tr>
</table>
<br>
</form>
</td>
</tr>
<tr>
<td>
<?php
include 'left.php';
?> </td>
</tr>
</table>
<br>
<br>
<?php
include 'end.php';
?>
</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -