⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upload.php

📁 实现考试管理系统
💻 PHP
字号:
<?php
ob_start();
session_start();
//if ($_SESSION['admininf']!=1) 
//{
//die("<div align=center>请先<a href=login.php><font color=blue>-- 登录 --</font></a></div>");
//}


//没页显示记录数
$PageSize = 10;
$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">
<style type="text/css">
<!--
.STYLE3 {color: #FFCC99}
-->
</style>
</head>
<?php
 include 'conn.php';
 $TRecord = mysql_query("SELECT * FROM upload");
 $result = mysql_query("SELECT * FROM upload ORDER BY  uploadid  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="760" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="101" colspan="2"><img src="image/houtaihead.gif" width="780" height="150" longdesc="image/houtaihead.gif" /></td>
    </tr>
  <tr>
    <td height="23" colspan="2" align="center" bgcolor="#FF9966"><font size="-1" color="blue"><?php echo date("20y年m月d日");?></font></td>
    </tr>
  <tr>
    <td width="150" height="14" background="images/top2.jpg"></td>
    <td width="610" rowspan="2" align="left">
	<form action="upload_reg.php" method="post" name="form1" enctype="multipart/form-data">
	<br>
	<table width="600" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse" >
      <tr>
        <td colspan="3" align="center"><span class="STYLE3"><font size="+2"><b>资料上传</b></font></span></td>
        </tr>
      <tr>
        <td colspan="3" align="right"><font color="#FF0000">*文件小于1000000字节才能上传.</font></td>
      </tr>
      <tr>
        <td width="120" height="31" align="center"><font size="-1">上传资料:</font></td>
        <td align="center"><input name="upload" type="file">
		<input type="hidden" name="MAX_FILE_SIZE" value="1000000">		</td>
        <td width="119" align="center"><input name="button2" type="submit" value="确认上传"></td>
      </tr>
      <tr>
        <td height="243" colspan="3" valign="top">
		<table width="100%" border="0" class="NormalTableTwo">
		  <tr>
		    <td colspan="2" class="AttachedFiles" align="center">
		      
		      
		      <font size=-1><?php print "总共".$RecordCount."条记录 - 当前页: $PageNo/$MaxPage" ?></font></td>
    </tr>
        </table>
		<table width="100%" border="1" bordercolor="#FFCC99" class="NormalTableTwo" cellspacing="3" cellpadding="2">
          <tr>
            <td width="8%" align="center" class="MandatoryFields">编号</td>
            <td width="33%" align="center" class="MandatoryFields">文件名</td>
            <td width="22%" align="center" class="MandatoryFields">文件大小</td>
            <td width="12%" align="center" class="MandatoryFields">上传时间</td>
            <td width="15%" 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[1] ?>
                <script language="JavaScript">
        function Confirmer<?php echo $i;?>()
          {
            if (confirm("确定要删除(<?php echo $row[1] ?>),以及与此相关的所有内容!"))
             {
                 window.location.href='dodelfile.php?id=<?php echo $row[1];?>';
             }
           }
          </script>
            </td>
            <td class="NormalTable" align="center"><?php echo $row[2] ?></td>
            <td class="NormalTable" align="center"><?php echo $row[3] ?></td>
            <td class="NormalTable" align="center"><?php echo $row[4] ?></td>
            
          </tr>
          <?php
  $i++;
}?>
        </table>
		<table width="100%" border="0" class="AttachedFiles" height="20">
		  <tr>
		    <td height="15">
		      <div align="center">
		        <?php
	  echo "<font size=+1 color=blue>";
        //显示第一页或者前一页的链接
		//如果当前页不是第1页,则显示第一页和前一页的链接
        if($PageNo != 1){
            $PrevStart = $PageNo - 1;
            print "<a href=upload.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=upload.php?PageNo=$c>$c</a> ";
                }else{
                    echo "<a href=upload.php?PageNo=$c>$c</a> ,";
                }//END IF
            }else{
                if($PageNo == $MaxPage){
                    print "$c ";
                    break;
                }else{
                    echo "<a href=upload.php?PageNo=$c>$c</a> ";
                    break;
                }//END IF
            }//END IF
       }//NEXT

      echo "] ";

	  

      if($PageNo < $MaxPage){  //如果当前页不是最后一页,则显示下一页链接
          $NextPage = $PageNo + 1;
          echo "<a href=upload.php?PageNo=$NextPage>下一页</a>";
      }
      
      //同时如果当前页补上最后一页,要显示最有一页的链接
      if($PageNo < $MaxPage){
       $LastRec = $RecordCount % $PageSize;
        if($LastRec == 0){
            $LastStartRecord = $RecordCount - $PageSize;
        }
        else{
            $LastStartRecord = $RecordCount - $LastRec;
        }

        print " : ";
        echo "<a href=upload.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 + -