我的LabPHP框架的Demo应用——课程设计题目统计系统

1、界面制作(为了方便起见,这里我采用了Bootstrap框架制作界面)

2数据库设计,正确创建students表;


admin表:


3、项目目录结构如下:


    LaPHP框架已经在上文中列出,这里就不再列出。

   Home模块(提供“新增题目”和“修改试题”、查看所有学生题目的功能):




       Application/Home/Config/config.PHP

  1. <?php   
  2.     return array(  
  3.         //'配置项'=>'配置值'  
  4.         'DB_HOST' => 'localhost'//设置主机  
  5.         'DB_USER' => 'root'//设置用户名  
  6.         'DB_PWD' => ''//设置密码  
  7.         'DB_PORT' => '3306'//设置端口号  
  8.         'DB_NAME' => 'mydb_329'//设置数据库名  
  9.   
  10.         /* 模板设置 */  
  11.         'TMPL_TEMPLATE_SUFFIX'  =>  '.php',     // 默认模板文件后缀  
  12.     );  
  13. ?>  
<?php 
	return array(
		//'配置项'=>'配置值'
		'DB_HOST' => 'localhost', //设置主机
		'DB_USER' => 'root', //设置用户名
		'DB_PWD' => '', //设置密码
		'DB_PORT' => '3306', //设置端口号
		'DB_NAME' => 'mydb_329', //设置数据库名

		/* 模板设置 */
	    'TMPL_TEMPLATE_SUFFIX'  =>  '.php',     // 默认模板文件后缀
	);
?>
     Application/Home/Controller/IndexController.class.php

  1. <?php   
  2.     class IndexController extends Controller {        
  3.         function index() {  
  4.             //echo "<p style='width: 50%; height: 300px; line-height: 300px; padding: 10px 20px; font-family:\"微软雅黑\", \"Microsoft YaHei\"; font-size: 30px; margin: 50px auto; box-shadow: 0 0 3px #ABCDEF; text-align: center; position: relative;'>Hello LabPHP!<span style='line-height: 30px; font-size: 20px; position: absolute; bottom: 20px; right: 20px;'>欢迎使用LapPHP V1.0.0   By DreamBoy<span></p>";  
  5.               
  6.             $students = M('Students'); //检查是否有错误提示  
  7.             if($res = $students->check()) {  
  8.                 $this->assign('err'$res);  
  9.             }  
  10.             $this->display();  
  11.         }  
  12.   
  13.         function doAction() {  
  14.             $students = M('Students');  
  15.             if($res = $students->checkForm()) { //验证表单字段  
  16.                 $this->assign('err'$res)->display('Index/index');  
  17.             } else {  
  18.                 if($this->validate($_POST['action'])) { //根据action执行相应操作  
  19.                     if($_POST['action'] == 'add') {  
  20.   
  21.                         if($students->add()) {  
  22.                             $this->assign('info''add')->show();  
  23.                         } else {  
  24.                             $this->redirect('Index/index''err=add');  
  25.                         }  
  26.   
  27.                     } else if($_POST['action'] == 'modify') {  
  28.                         if($students->modify()) {  
  29.                             $this->assign('info''modify')->show();  
  30.                         } else {  
  31.                             $this->redirect('Index/index''err=modify');  
  32.                         }  
  33.                     }  
  34.                 }  
  35.             }  
  36.         }  
  37.   
  38.         //显示所有信息  
  39.         function show() {  
  40.             $students = M('Students');  
  41.             $cur = 1; //当前页数第一页  
  42.             if($this->validate($_GET['cur'])) {  
  43.                 $cur = $_GET['cur'];  
  44.             }  
  45.             $res = $students->page($cur);  
  46.             $this->assign('res'$res)->assign('start', ($cur-1) * $students->getEachPageLen() + 1)->assign('prePage'$cur-1)->assign('nextPage'$cur+1)->display('Index/showStudent');  
  47.         }  
  48.     }  
  49. ?>  
<?php 
	class IndexController extends Controller {		
		function index() {
			//echo "<p style='width: 50%; height: 300px; line-height: 300px; padding: 10px 20px; font-family:\"微软雅黑\", \"Microsoft YaHei\"; font-size: 30px; margin: 50px auto; box-shadow: 0 0 3px #ABCDEF; text-align: center; position: relative;'>Hello LabPHP!<span style='line-height: 30px; font-size: 20px; position: absolute; bottom: 20px; right: 20px;'>欢迎使用LapPHP V1.0.0   By DreamBoy<span></p>";
			
			$students = M('Students'); //检查是否有错误提示
			if($res = $students->check()) {
				$this->assign('err', $res);
			}
			$this->display();
		}

		function doAction() {
			$students = M('Students');
			if($res = $students->checkForm()) { //验证表单字段
				$this->assign('err', $res)->display('Index/index');
			} else {
				if($this->validate($_POST['action'])) { //根据action执行相应操作
					if($_POST['action'] == 'add') {

						if($students->add()) {
							$this->assign('info', 'add')->show();
						} else {
							$this->redirect('Index/index', 'err=add');
						}

					} else if($_POST['action'] == 'modify') {
						if($students->modify()) {
							$this->assign('info', 'modify')->show();
						} else {
							$this->redirect('Index/index', 'err=modify');
						}
					}
				}
			}
		}

		//显示所有信息
		function show() {
			$students = M('Students');
			$cur = 1; //当前页数第一页
			if($this->validate($_GET['cur'])) {
				$cur = $_GET['cur'];
			}
			$res = $students->page($cur);
			$this->assign('res', $res)->assign('start', ($cur-1) * $students->getEachPageLen() + 1)->assign('prePage', $cur-1)->assign('nextPage', $cur+1)->display('Index/showStudent');
		}
	}
?>

     Application/Home/Model/StudentsModel.class.php

  1. <?php   
  2.     class StudentsModel extends Model {  
  3.         private static $err = array('sno'=>'学生学号不能为空!''name'=>'学生姓名不能为空!''psw'=>'修改密码不能为空''title'=>'题目标题不能为空!''add'=>'新增题目失败,原因可能为已新增过题目了,请尝试选择“修改试题”进行提交!''modify'=>'修改试题失败,原因可能为:1.未新增过题目;2.学生学号输入错误;3.修改密码输入错误!');  
  4.         private $eachPageLen = 15;  
  5.   
  6.         /** 
  7.          * 检查是否有错误提示 
  8.          * @return [type] [description] 
  9.          */  
  10.         function check() {  
  11.             if($this->validate($_GET['err'])) {  
  12.                 return self::$err[$_GET['err']];  
  13.             }  
  14.             return '';  
  15.         }  
  16.   
  17.         /** 
  18.          * 检查新增题目或修改试题的提交过来的表单字段 
  19.          * @return [type] [description] 
  20.          */  
  21.         function checkForm() {  
  22.             $required = array('sno'=>'学生学号不能为空!''name'=>'学生姓名不能为空!''psw'=>'修改密码不能为空''title'=>'题目标题不能为空!');  
  23.   
  24.             foreach ($required as $key => $value) {  
  25.                 if(!$this->validate($_POST[$key])) {  
  26.                     return $value;  
  27.                 }  
  28.             }  
  29.             return '';  
  30.         }  
  31.   
  32.         //新增数据  
  33.         function add() {  
  34.             $sno = $_POST['sno'];  
  35.             $name = $_POST['name'];  
  36.             $psw = $_POST['psw'];  
  37.             $title = $_POST['title'];  
  38.             $partner = $_POST['partner'];  
  39.   
  40.             $sql = "INSERT INTO students(`sno`, `name`, `psw`, `title`, `last_time`, `partner`) VALUES('$sno', '$name', '$psw', '$title', now(), '$partner')";  
  41.   
  42.             $res = $this->execute_dml($sql);  
  43.             if($res == 1) {  
  44.                 return 1; //新增题目成功  
  45.             } else {  
  46.                 return 0; //新增题目失败  
  47.             }  
  48.         }  
  49.   
  50.         //修改数据  
  51.         function modify() {  
  52.             $sno = $_POST['sno'];  
  53.             $psw = $_POST['psw'];  
  54.             $title = $_POST['title'];  
  55.             $partner = !isset($_POST['partner']) || empty($_POST['partner']) ? '' : $_POST['partner'];  
  56.   
  57.             $sql = "UPDATE students SET `title` = '$title', `partner` = '$partner' WHERE `sno` = '$sno' AND `psw` = '$psw'";  
  58.   
  59.             $res = $this->execute_dml($sql);  
  60.             if($res == 1) {  
  61.                 return 1; //修改题目成功  
  62.             } else {  
  63.                 return 0; //修改题目失败  
  64.             }  
  65.         }  
  66.   
  67.         //分页查询数据  
  68.         function page($cur) {  
  69.             $length = $this->eachPageLen;  
  70.             $offset = ($cur - 1) * $length;  
  71.             $sql = "SELECT * FROM students ORDER BY sno LIMIT $offset,$length";  
  72.             return $arr = $this->execute_dql_arr($sql);  
  73.         }  
  74.         //得到每页的页数  
  75.         function getEachPageLen() {  
  76.             return $this->eachPageLen;  
  77.         }  
  78.     }  
  79. ?>  
<?php 
	class StudentsModel extends Model {
		private static $err = array('sno'=>'学生学号不能为空!', 'name'=>'学生姓名不能为空!', 'psw'=>'修改密码不能为空', 'title'=>'题目标题不能为空!', 'add'=>'新增题目失败,原因可能为已新增过题目了,请尝试选择“修改试题”进行提交!', 'modify'=>'修改试题失败,原因可能为:1.未新增过题目;2.学生学号输入错误;3.修改密码输入错误!');
		private $eachPageLen = 15;

		/**
		 * 检查是否有错误提示
		 * @return [type] [description]
		 */
		function check() {
			if($this->validate($_GET['err'])) {
				return self::$err[$_GET['err']];
			}
			return '';
		}

		/**
		 * 检查新增题目或修改试题的提交过来的表单字段
		 * @return [type] [description]
		 */
		function checkForm() {
			$required = array('sno'=>'学生学号不能为空!', 'name'=>'学生姓名不能为空!', 'psw'=>'修改密码不能为空', 'title'=>'题目标题不能为空!');

			foreach ($required as $key => $value) {
				if(!$this->validate($_POST[$key])) {
					return $value;
				}
			}
			return '';
		}

		//新增数据
		function add() {
			$sno = $_POST['sno'];
			$name = $_POST['name'];
			$psw = $_POST['psw'];
			$title = $_POST['title'];
			$partner = $_POST['partner'];

			$sql = "INSERT INTO students(`sno`, `name`, `psw`, `title`, `last_time`, `partner`) VALUES('$sno', '$name', '$psw', '$title', now(), '$partner')";

			$res = $this->execute_dml($sql);
			if($res == 1) {
				return 1; //新增题目成功
			} else {
				return 0; //新增题目失败
			}
		}

		//修改数据
		function modify() {
			$sno = $_POST['sno'];
			$psw = $_POST['psw'];
			$title = $_POST['title'];
			$partner = !isset($_POST['partner']) || empty($_POST['partner']) ? '' : $_POST['partner'];

			$sql = "UPDATE students SET `title` = '$title', `partner` = '$partner' WHERE `sno` = '$sno' AND `psw` = '$psw'";

			$res = $this->execute_dml($sql);
			if($res == 1) {
				return 1; //修改题目成功
			} else {
				return 0; //修改题目失败
			}
		}

		//分页查询数据
		function page($cur) {
			$length = $this->eachPageLen;
			$offset = ($cur - 1) * $length;
			$sql = "SELECT * FROM students ORDER BY sno LIMIT $offset,$length";
			return $arr = $this->execute_dql_arr($sql);
		}
		//得到每页的页数
		function getEachPageLen() {
			return $this->eachPageLen;
		}
	}
?>

    Application/Home/View/Index/index.php

  1. <!DOCTYPE html>  
  2. <html lang="zh-CN">  
  3.   <head>  
  4.     <meta charset="utf-8">  
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">  
  6.     <meta name="viewport" content="width=device-width, initial-scale=1">  
  7.     <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->  
  8.     <title>课程设计题目统计系统</title>  
  9.   
  10.     <!-- Bootstrap -->  
  11.     <link href="Public/css/bootstrap.min.css" rel="stylesheet">  
  12.     <link href="Public/style.css" rel="stylesheet" type="text/css"/>  
  13.   
  14.     <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->  
  15.     <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->  
  16.     <!--[if lt IE 9]>  
  17.       <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>  
  18.       <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>  
  19.     <![endif]-->  
  20.   </head>  
  21.   <body>  
  22.     <div class="container">  
  23.       <div class="col-sm-3"></div>  
  24.       <div class="col-sm-6 content">  
  25.         <h2>课程设计题目统计系统</h2>  
  26.         <form class="form-horizontal" action="index.php?a=doAction" method="POST">  
  27.           <div class="form-group">  
  28.             <label for="number" class="col-sm-3 control-label">学生学号:</label>  
  29.             <div class="col-sm-9">  
  30.               <input type="text" class="form-control" id="number" placeholder="输入12位学号" name="sno">  
  31.             </div>  
  32.           </div>  
  33.           <div class="form-group">  
  34.             <label for="name" class="col-sm-3 control-label">学生姓名:</label>  
  35.             <div class="col-sm-9">  
  36.               <input type="text" class="form-control" id="name" placeholder="姓名" name="name">  
  37.             </div>  
  38.           </div>  
  39.           <div class="form-group">  
  40.             <label for="password" class="col-sm-3 control-label">修改密码:</label>  
  41.             <div class="col-sm-9">  
  42.               <input type="password" class="form-control" id="password" placeholder="首次输入作为后面修改的密码" name="psw">  
  43.             </div>  
  44.           </div>  
  45.           <div class="form-group">  
  46.             <label for="title" class="col-sm-3 control-label">你的题目:</label>  
  47.             <div class="col-sm-9">  
  48.               <input type="text" class="form-control" id="title" placeholder="按照课程设计题目要求" name="title">  
  49.             </div>  
  50.           </div>  
  51.           <div class="form-group">  
  52.             <label for="name" class="col-sm-3 control-label">合作学生:</label>  
  53.             <div class="col-sm-9">  
  54.               <input type="text" class="form-control" id="name" placeholder="姓名,没有就空,只负责不同方面" name="partner">  
  55.             </div>  
  56.           </div>  
  57.           <div class="form-group">  
  58.             <div class="col-sm-offset-3 col-sm-9">  
  59.                 <label>  
  60.                   <input type="radio" name="action" value="add"  checked="checked"> 新增题目  
  61.                 </label>  
  62.                     
  63.                 <label>  
  64.                   <input type="radio" name="action" value="modify"> 修改试题  
  65.                 </label>  
  66.             </div>  
  67.           </div>  
  68.           <div class="form-group">  
  69.             <div class="col-sm-offset-3 col-sm-9">  
  70.               <button type="submit" class="btn btn-info">提交操作</button>     
  71.               <a href="index.php?a=show">显示全部学生题目</a>  
  72.             </div>  
  73.           </div>  
  74.           <?php  
  75.             if($err) {  
  76.           ?>  
  77.                <p class="info"><span style="font-weight: bold">错误:</span><?php echo $err;?></p>  
  78.           <?php  
  79.             }  
  80.           ?>  
  81.         </form>  
  82.       </div>  
  83.       <div class="col-sm-3"></div>  
  84.     </div>  
  85.   
  86.     <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->  
  87.     <script src="Public/js/jquery.min.js"></script>  
  88.     <!-- Include all compiled plugins (below), or include individual files as needed -->  
  89.     <script src="Public/js/bootstrap.min.js"></script>  
  90.   </body>  
  91. </html>  
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
    <title>课程设计题目统计系统</title>

    <!-- Bootstrap -->
    <link href="Public/css/bootstrap.min.css" rel="stylesheet">
    <link href="Public/style.css" rel="stylesheet" type="text/css"/>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <div class="container">
      <div class="col-sm-3"></div>
      <div class="col-sm-6 content">
        <h2>课程设计题目统计系统</h2>
        <form class="form-horizontal" action="index.php?a=doAction" method="POST">
          <div class="form-group">
            <label for="number" class="col-sm-3 control-label">学生学号:</label>
            <div class="col-sm-9">
              <input type="text" class="form-control" id="number" placeholder="输入12位学号" name="sno">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">学生姓名:</label>
            <div class="col-sm-9">
              <input type="text" class="form-control" id="name" placeholder="姓名" name="name">
            </div>
          </div>
          <div class="form-group">
            <label for="password" class="col-sm-3 control-label">修改密码:</label>
            <div class="col-sm-9">
              <input type="password" class="form-control" id="password" placeholder="首次输入作为后面修改的密码" name="psw">
            </div>
          </div>
          <div class="form-group">
            <label for="title" class="col-sm-3 control-label">你的题目:</label>
            <div class="col-sm-9">
              <input type="text" class="form-control" id="title" placeholder="按照课程设计题目要求" name="title">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">合作学生:</label>
            <div class="col-sm-9">
              <input type="text" class="form-control" id="name" placeholder="姓名,没有就空,只负责不同方面" name="partner">
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-offset-3 col-sm-9">
                <label>
                  <input type="radio" name="action" value="add"  checked="checked"> 新增题目
                </label>
                  
                <label>
                  <input type="radio" name="action" value="modify"> 修改试题
                </label>
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-offset-3 col-sm-9">
              <button type="submit" class="btn btn-info">提交操作</button>   
              <a href="index.php?a=show">显示全部学生题目</a>
            </div>
          </div>
          <?php
            if($err) {
          ?>
               <p class="info"><span style="font-weight: bold">错误:</span><?php echo $err;?></p>
          <?php
            }
          ?>
        </form>
      </div>
      <div class="col-sm-3"></div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="Public/js/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="Public/js/bootstrap.min.js"></script>
  </body>
</html>

   Application/Home/View/Index/showStudent.php

  1. <!DOCTYPE html>  
  2. <html lang="zh-CN">  
  3.   <head>  
  4.     <meta charset="utf-8">  
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">  
  6.     <meta name="viewport" content="width=device-width, initial-scale=1">  
  7.     <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->  
  8.     <title>课程设计题目统计系统</title>  
  9.   
  10.     <!-- Bootstrap -->  
  11.     <link href="Public/css/bootstrap.min.css" rel="stylesheet">  
  12.     <link href="Public/style.css" rel="stylesheet" type="text/css"/>  
  13.     <style>  
  14.       p.info {  
  15.         margin-bottom: 0;  
  16.       }  
  17.     </style>  
  18.   
  19.     <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->  
  20.     <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->  
  21.     <!--[if lt IE 9]>  
  22.       <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>  
  23.       <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>  
  24.     <![endif]-->  
  25.   </head>  
  26.   <body>  
  27.     <div class="container">  
  28.       <div class="content">  
  29.         <?php  
  30.           if($info) {  
  31.             if($info == 'add') {  
  32.               $fo = '新增';  
  33.             } else if($info == 'modify') {  
  34.               $fo = '修改';  
  35.             }  
  36.         ?>  
  37.              <p class="info"><marquee behavior="scroll" direction="left"><span style="font-weight: bold">消息:</span><?php echo $fo . '题目成功!';?></marquee></p>  
  38.         <?php  
  39.           }  
  40.         ?>  
  41.           
  42.         <table class="table table-hover">  
  43.           <caption><h3>学生课程设计题目</h3></caption>  
  44.           <?php  
  45.             if(!isset($res) || empty($res)) {  
  46.               echo '<tr><td>暂无学生题目</td></tr>';  
  47.             } else {  
  48.           ?>  
  49.           <thead>  
  50.             <tr>  
  51.               <!-- <th>删除</th> -->  
  52.               <th>序号</th>  
  53.               <th>学号</th>  
  54.               <th>姓名</th>  
  55.               <th>题目</th>  
  56.               <th>状态</th>  
  57.               <th>录入时间</th>  
  58.               <th>合作学生</th>  
  59.             </tr>  
  60.           </thead>  
  61.           <tbody>  
  62.             <?php  
  63.               $i = $start ? $start : 1;  
  64.               foreach ($res as $value) {  
  65.                 echo '<tr>';  
  66.                 echo "<th scope='row'>$i</th>";  
  67.                 echo "<td>{$value['sno']}</td>";   
  68.                 echo "<td>{$value['name']}</td>";   
  69.                 echo "<td>{$value['title']}</td>";   
  70.                 echo "<td>{$value['state']}</td>";   
  71.                 echo "<td>{$value['last_time']}</td>";   
  72.                 echo "<td>{$value['partner']}</td>";   
  73.                 echo '</tr>';  
  74.                 $i++;  
  75.               }  
  76.             ?>  
  77.           </tbody>  
  78.           <?php  
  79.             }  
  80.           ?>  
  81.         </table>  
  82.         <nav>  
  83.           <ul class="pager">  
  84.             <li>  
  85.               <?php  
  86.                 if($prePage) {  
  87.                   if($prePage >= 1) {  
  88.                     echo "<a href='index.php?a=show&cur=$prePage'>上一页</a>";  
  89.                   }  
  90.                 }  
  91.               ?>  
  92.             </li>  
  93.             <li>  
  94.               <?php  
  95.                 if($nextPage) {  
  96.                   if($nextPage >= 1) {  
  97.                     echo "<a href='index.php?a=show&cur=$nextPage'>下一页</a>";  
  98.                   }  
  99.                 }  
  100.               ?>  
  101.             </li>  
  102.           </ul>  
  103.         </nav>  
  104.         <a href="index.php">返回输入界面</a>  
  105.       </div>  
  106.     </div>  
  107.   
  108.     <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->  
  109.     <script src="Public/js/jquery.min.js"></script>  
  110.     <!-- Include all compiled plugins (below), or include individual files as needed -->  
  111.     <script src="Public/js/bootstrap.min.js"></script>  
  112.   </body>  
  113. </html>  
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
    <title>课程设计题目统计系统</title>

    <!-- Bootstrap -->
    <link href="Public/css/bootstrap.min.css" rel="stylesheet">
    <link href="Public/style.css" rel="stylesheet" type="text/css"/>
    <style>
      p.info {
        margin-bottom: 0;
      }
    </style>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
	<div class="container">
      <div class="content">
        <?php
          if($info) {
            if($info == 'add') {
              $fo = '新增';
            } else if($info == 'modify') {
              $fo = '修改';
            }
        ?>
             <p class="info"><marquee behavior="scroll" direction="left"><span style="font-weight: bold">消息:</span><?php echo $fo . '题目成功!';?></marquee></p>
        <?php
          }
        ?>
        
        <table class="table table-hover">
          <caption><h3>学生课程设计题目</h3></caption>
          <?php
            if(!isset($res) || empty($res)) {
              echo '<tr><td>暂无学生题目</td></tr>';
            } else {
          ?>
          <thead>
            <tr>
              <!-- <th>删除</th> -->
              <th>序号</th>
              <th>学号</th>
              <th>姓名</th>
              <th>题目</th>
              <th>状态</th>
              <th>录入时间</th>
              <th>合作学生</th>
            </tr>
          </thead>
          <tbody>
            <?php
              $i = $start ? $start : 1;
              foreach ($res as $value) {
                echo '<tr>';
                echo "<th scope='row'>$i</th>";
                echo "<td>{$value['sno']}</td>"; 
                echo "<td>{$value['name']}</td>"; 
                echo "<td>{$value['title']}</td>"; 
                echo "<td>{$value['state']}</td>"; 
                echo "<td>{$value['last_time']}</td>"; 
                echo "<td>{$value['partner']}</td>"; 
                echo '</tr>';
                $i++;
              }
            ?>
          </tbody>
          <?php
            }
          ?>
        </table>
        <nav>
          <ul class="pager">
            <li>
              <?php
                if($prePage) {
                  if($prePage >= 1) {
                    echo "<a href='index.php?a=show&cur=$prePage'>上一页</a>";
                  }
                }
              ?>
            </li>
            <li>
              <?php
                if($nextPage) {
                  if($nextPage >= 1) {
                    echo "<a href='index.php?a=show&cur=$nextPage'>下一页</a>";
                  }
                }
              ?>
            </li>
          </ul>
        </nav>
        <a href="index.php">返回输入界面</a>
      </div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="Public/js/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="Public/js/bootstrap.min.js"></script>
  </body>
</html>

     Admin模块(提供管理员登陆和删除功能):






         Application/Admin/Config/config.php

  1. <?php   
  2.     return array(  
  3.         //'配置项'=>'配置值'  
  4.         'DB_HOST' => 'localhost'//设置主机  
  5.         'DB_USER' => 'root'//设置用户名  
  6.         'DB_PWD' => ''//设置密码  
  7.         'DB_PORT' => '3306'//设置端口号  
  8.         'DB_NAME' => 'mydb_329'//设置数据库名  
  9.   
  10.         /* 模板设置 */  
  11.         'TMPL_TEMPLATE_SUFFIX'  =>  '.php',     // 默认模板文件后缀  
  12.     );  
  13. ?>  
<?php 
	return array(
		//'配置项'=>'配置值'
		'DB_HOST' => 'localhost', //设置主机
		'DB_USER' => 'root', //设置用户名
		'DB_PWD' => '', //设置密码
		'DB_PORT' => '3306', //设置端口号
		'DB_NAME' => 'mydb_329', //设置数据库名

		/* 模板设置 */
	    'TMPL_TEMPLATE_SUFFIX'  =>  '.php',     // 默认模板文件后缀
	);
?>
     Application/Admin/Controller/IndexController.class.php

  1. <?php   
  2.     class IndexController extends Controller {        
  3.         function index() {  
  4.             //echo "<p style='width: 50%; height: 300px; line-height: 300px; padding: 10px 20px; font-family:\"微软雅黑\", \"Microsoft YaHei\"; font-size: 30px; margin: 50px auto; box-shadow: 0 0 3px #ABCDEF; text-align: center; position: relative;'>Hello LabPHP!<span style='line-height: 30px; font-size: 20px; position: absolute; bottom: 20px; right: 20px;'>欢迎使用LapPHP V1.0.0   By DreamBoy<span></p>";  
  5.               
  6.             $this->display();  
  7.         }  
  8.   
  9.         function check() {  
  10.             $admin = M('Admin'); //检查是否有错误提示  
  11.             if($res = $admin->check()) { //验证失败!有错误提示  
  12.                 $this->assign('err'$res);  
  13.                 $this->display('Index/index');  
  14.             } else {  
  15.                 $this->redirect('Index/adminShow');  
  16.             }  
  17.         }  
  18.   
  19.         /** 
  20.          * 验证是否登陆过 
  21.          * @return boolean [description] 
  22.          */  
  23.         function isLogin() {  
  24.             session_start();  
  25.             if(!$this->validate($_SESSION['account'])) {  
  26.                 $this->assign('err''请先登录!')->display('Index/index');  
  27.             }  
  28.         }  
  29.   
  30.         //显示所有信息  
  31.         function show() {  
  32.             $this->isLogin();  
  33.   
  34.             $students = M('Students');  
  35.             $cur = 1; //当前页数第一页  
  36.             if($this->validate($_GET['cur'])) {  
  37.                 $cur = $_GET['cur'];  
  38.             }  
  39.             $res = $students->page($cur);  
  40.             $this->assign('res'$res)->assign('start', ($cur-1) * $students->getEachPageLen() + 1)->assign('prePage'$cur-1)->assign('nextPage'$cur+1)->display('Index/showStudent');  
  41.         }  
  42.   
  43.         //显示所有信息+删除操作  
  44.         function adminShow() {  
  45.             $this->isLogin();  
  46.   
  47.             $students = M('Students');  
  48.             $cur = 1; //当前页数第一页  
  49.             if($this->validate($_GET['cur'])) {  
  50.                 $cur = $_GET['cur'];  
  51.             }  
  52.             $res = $students->page($cur);  
  53.             $this->assign('res'$res)->assign('start', ($cur-1) * $students->getEachPageLen() + 1)->assign('prePage'$cur-1)->assign('nextPage'$cur+1)->display('Index/admin');  
  54.         }  
  55.   
  56.         //删除学生题目  
  57.         function del() {  
  58.             //print_r($_POST['sno']);  
  59.             $admin = M('Admin');  
  60.             $res = $admin->del();  
  61.             if($res == 1) {  
  62.                 $this->assign('info''删除成功!');  
  63.             } else if($res == -1) {  
  64.                 $this->assign('info''删除失败!');  
  65.             } else if($res == 0) {  
  66.                 $this->assign('info''没有删除任何数据');  
  67.             }  
  68.             $this->adminShow();  
  69.         }  
  70.     }  
  71. ?>  
<?php 
	class IndexController extends Controller {		
		function index() {
			//echo "<p style='width: 50%; height: 300px; line-height: 300px; padding: 10px 20px; font-family:\"微软雅黑\", \"Microsoft YaHei\"; font-size: 30px; margin: 50px auto; box-shadow: 0 0 3px #ABCDEF; text-align: center; position: relative;'>Hello LabPHP!<span style='line-height: 30px; font-size: 20px; position: absolute; bottom: 20px; right: 20px;'>欢迎使用LapPHP V1.0.0   By DreamBoy<span></p>";
			
			$this->display();
		}

		function check() {
			$admin = M('Admin'); //检查是否有错误提示
			if($res = $admin->check()) { //验证失败!有错误提示
				$this->assign('err', $res);
				$this->display('Index/index');
			} else {
				$this->redirect('Index/adminShow');
			}
		}

		/**
		 * 验证是否登陆过
		 * @return boolean [description]
		 */
		function isLogin() {
			session_start();
			if(!$this->validate($_SESSION['account'])) {
				$this->assign('err', '请先登录!')->display('Index/index');
			}
		}

		//显示所有信息
		function show() {
			$this->isLogin();

			$students = M('Students');
			$cur = 1; //当前页数第一页
			if($this->validate($_GET['cur'])) {
				$cur = $_GET['cur'];
			}
			$res = $students->page($cur);
			$this->assign('res', $res)->assign('start', ($cur-1) * $students->getEachPageLen() + 1)->assign('prePage', $cur-1)->assign('nextPage', $cur+1)->display('Index/showStudent');
		}

		//显示所有信息+删除操作
		function adminShow() {
			$this->isLogin();

			$students = M('Students');
			$cur = 1; //当前页数第一页
			if($this->validate($_GET['cur'])) {
				$cur = $_GET['cur'];
			}
			$res = $students->page($cur);
			$this->assign('res', $res)->assign('start', ($cur-1) * $students->getEachPageLen() + 1)->assign('prePage', $cur-1)->assign('nextPage', $cur+1)->display('Index/admin');
		}

		//删除学生题目
		function del() {
			//print_r($_POST['sno']);
			$admin = M('Admin');
			$res = $admin->del();
			if($res == 1) {
				$this->assign('info', '删除成功!');
			} else if($res == -1) {
				$this->assign('info', '删除失败!');
			} else if($res == 0) {
				$this->assign('info', '没有删除任何数据');
			}
			$this->adminShow();
		}
	}
?>
      Application/Admin/Model/AdminModel.class.php

  1. <?php   
  2.     class AdminModel extends Model {  
  3.         private static $err = array('account'=>'管理员账号不能为空!''psw'=>'管理员密码不能为空!''none'=>'该账号不存在!''pswErr'=>'密码错误!');  
  4.   
  5.         function check() {  
  6.             //验证管理员账号是否为空  
  7.             if(!$this->validate(daddslashes($_POST['account']))) {  
  8.                 return self::$err['account'];  
  9.             }  
  10.   
  11.             //验证管理员密码是否为空  
  12.             if(!$this->validate(daddslashes($_POST['psw']))) {  
  13.                 return self::$err['psw'];  
  14.             }  
  15.   
  16.             $account = daddslashes($_POST['account']);  
  17.             $psw = daddslashes($_POST['psw']);  
  18.             $sql = "SELECT `psw` FROM `admin` WHERE `account`='$account'";  
  19.             $res = $this->execute_dql_arr($sql);  
  20.             if($this->validate($res)) {  
  21.                 if($res[0]['psw'] != $psw) {  
  22.                     return self::$err['pswErr'];  
  23.                 }  
  24.             } else {  
  25.                 return self::$err['none'];  
  26.             }  
  27.   
  28.             //验证通过  
  29.             session_start();  
  30.             $_SESSION['account'] = $account;  
  31.             return '';  
  32.         }  
  33.   
  34.         //删除学生题目  
  35.         function del() {  
  36.             if($this->validate($_POST['sno'])) {  
  37.                 $snoArr = $_POST['sno']; //获取用户选择的sno数组  
  38.                 $snos = implode(','$snoArr);  
  39.                 $sql = "DELETE FROM `students` WHERE `sno` IN ($snos)";  
  40.                 $res = $this->execute_dml($sql);  
  41.                 if($res == 1) {  
  42.                     return 1; //新增题目成功  
  43.                 } else {  
  44.                     return 0; //新增题目失败  
  45.                 }  
  46.             } else {  
  47.                 return -1; //没有题目可删除  
  48.             }  
  49.         }  
  50.     }  
  51. ?>  
<?php 
	class AdminModel extends Model {
		private static $err = array('account'=>'管理员账号不能为空!', 'psw'=>'管理员密码不能为空!', 'none'=>'该账号不存在!', 'pswErr'=>'密码错误!');

		function check() {
			//验证管理员账号是否为空
			if(!$this->validate(daddslashes($_POST['account']))) {
				return self::$err['account'];
			}

			//验证管理员密码是否为空
			if(!$this->validate(daddslashes($_POST['psw']))) {
				return self::$err['psw'];
			}

			$account = daddslashes($_POST['account']);
			$psw = daddslashes($_POST['psw']);
			$sql = "SELECT `psw` FROM `admin` WHERE `account`='$account'";
			$res = $this->execute_dql_arr($sql);
			if($this->validate($res)) {
				if($res[0]['psw'] != $psw) {
					return self::$err['pswErr'];
				}
			} else {
				return self::$err['none'];
			}

			//验证通过
			session_start();
			$_SESSION['account'] = $account;
			return '';
		}

		//删除学生题目
		function del() {
			if($this->validate($_POST['sno'])) {
				$snoArr = $_POST['sno']; //获取用户选择的sno数组
				$snos = implode(',', $snoArr);
				$sql = "DELETE FROM `students` WHERE `sno` IN ($snos)";
				$res = $this->execute_dml($sql);
				if($res == 1) {
					return 1; //新增题目成功
				} else {
					return 0; //新增题目失败
				}
			} else {
				return -1; //没有题目可删除
			}
		}
	}
?>
       Application/Admin/Model/StudentsModel.class.php

  1. <?php   
  2.     class StudentsModel extends Model {  
  3.         private $eachPageLen = 15;  
  4.   
  5.         //分页查询数据  
  6.         function page($cur) {  
  7.             $length = $this->eachPageLen;  
  8.             $offset = ($cur - 1) * $length;  
  9.             $sql = "SELECT * FROM students ORDER BY sno LIMIT $offset,$length";  
  10.             return $arr = $this->execute_dql_arr($sql);  
  11.         }  
  12.         //得到每页的页数  
  13.         function getEachPageLen() {  
  14.             return $this->eachPageLen;  
  15.         }  
  16.     }  
  17. ?>  
<?php 
	class StudentsModel extends Model {
		private $eachPageLen = 15;

		//分页查询数据
		function page($cur) {
			$length = $this->eachPageLen;
			$offset = ($cur - 1) * $length;
			$sql = "SELECT * FROM students ORDER BY sno LIMIT $offset,$length";
			return $arr = $this->execute_dql_arr($sql);
		}
		//得到每页的页数
		function getEachPageLen() {
			return $this->eachPageLen;
		}
	}
?>

       Application/Admin/View/Index/admin.php

  1. <!DOCTYPE html>  
  2. <html lang="zh-CN">  
  3.   <head>  
  4.     <meta charset="utf-8">  
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">  
  6.     <meta name="viewport" content="width=device-width, initial-scale=1">  
  7.     <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->  
  8.     <title>课程设计题目统计后台管理系统</title>  
  9.   
  10.     <!-- Bootstrap -->  
  11.     <link href="Public/css/bootstrap.min.css" rel="stylesheet">  
  12.     <link href="Public/style.css" rel="stylesheet" type="text/css"/>  
  13.     <style>  
  14.       p.info {  
  15.         margin-bottom: 0;  
  16.       }  
  17.     </style>  
  18.   
  19.     <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->  
  20.     <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->  
  21.     <!--[if lt IE 9]>  
  22.       <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>  
  23.       <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>  
  24.     <![endif]-->  
  25.   </head>  
  26.   <body>  
  27.     <div class="container">  
  28.       <div class="content">     
  29.         <?php  
  30.           if($info) {  
  31.         ?>  
  32.              <p class="info"><marquee behavior="scroll" direction="left"><span style="font-weight: bold">消息:</span><?php echo $info;?></marquee></p>  
  33.         <?php  
  34.           }  
  35.         ?>  
  36.         <form action="index.php?m=Admin&a=del" method="POST">  
  37.           <table class="table table-hover">  
  38.             <caption><h3>学生课程设计题目</h3></caption>  
  39.             <?php  
  40.               if(!isset($res) || empty($res)) {  
  41.                 echo '<tr><td>暂无学生题目</td></tr>';  
  42.               } else {  
  43.             ?>  
  44.             <thead>  
  45.               <tr>  
  46.                 <th>删除</th>  
  47.                 <th>序号</th>  
  48.                 <th>学号</th>  
  49.                 <th>姓名</th>  
  50.                 <th>题目</th>  
  51.                 <th>状态</th>  
  52.                 <th>录入时间</th>  
  53.                 <th>合作学生</th>  
  54.               </tr>  
  55.             </thead>  
  56.             <tbody>  
  57.               <?php  
  58.                 $i = $start ? $start : 1;  
  59.                 foreach ($res as $value) {  
  60.                   echo '<tr>';  
  61.                   echo '<td><input type="checkbox" name="sno[]" value="' . $value['sno'] . '"/></td>';  
  62.                   echo "<th scope='row'>$i</th>";  
  63.                   echo "<td>{$value['sno']}</td>";   
  64.                   echo "<td>{$value['name']}</td>";   
  65.                   echo "<td>{$value['title']}</td>";   
  66.                   echo "<td>{$value['state']}</td>";   
  67.                   echo "<td>{$value['last_time']}</td>";   
  68.                   echo "<td>{$value['partner']}</td>";   
  69.                   echo '</tr>';  
  70.                   $i++;  
  71.                 }  
  72.               ?>  
  73.             </tbody>  
  74.             <?php  
  75.               }  
  76.             ?>  
  77.           </table>  
  78.           <nav>  
  79.             <ul class="pager">  
  80.               <li>  
  81.                 <?php  
  82.                   if($prePage) {  
  83.                     if($prePage >= 1) {  
  84.                       echo "<a href='index.php?m=Admin&a=adminShow&cur=$prePage'>上一页</a>";  
  85.                     }  
  86.                   }  
  87.                 ?>  
  88.               </li>  
  89.               <li>  
  90.                 <?php  
  91.                   if($nextPage) {  
  92.                     if($nextPage >= 1) {  
  93.                       echo "<a href='index.php?m=Admin&a=adminShow&cur=$nextPage'>下一页</a>";  
  94.                     }  
  95.                   }  
  96.                 ?>  
  97.               </li>  
  98.             </ul>  
  99.           </nav>  
  100.           <a href="index.php?m=Admin">返回登陆界面</a>     <input class="btn btn-default" type="submit" value="确认删除"/>  
  101.         </form>  
  102.       </div>  
  103.     </div>  
  104.   
  105.     <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->  
  106.     <script src="Public/js/jquery.min.js"></script>  
  107.     <!-- Include all compiled plugins (below), or include individual files as needed -->  
  108.     <script src="Public/js/bootstrap.min.js"></script>  
  109.   </body>  
  110. </html>  
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
    <title>课程设计题目统计后台管理系统</title>

    <!-- Bootstrap -->
    <link href="Public/css/bootstrap.min.css" rel="stylesheet">
    <link href="Public/style.css" rel="stylesheet" type="text/css"/>
    <style>
      p.info {
        margin-bottom: 0;
      }
    </style>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
	<div class="container">
      <div class="content">   
        <?php
          if($info) {
        ?>
             <p class="info"><marquee behavior="scroll" direction="left"><span style="font-weight: bold">消息:</span><?php echo $info;?></marquee></p>
        <?php
          }
        ?>
        <form action="index.php?m=Admin&a=del" method="POST">
          <table class="table table-hover">
            <caption><h3>学生课程设计题目</h3></caption>
            <?php
              if(!isset($res) || empty($res)) {
                echo '<tr><td>暂无学生题目</td></tr>';
              } else {
            ?>
            <thead>
              <tr>
                <th>删除</th>
                <th>序号</th>
                <th>学号</th>
                <th>姓名</th>
                <th>题目</th>
                <th>状态</th>
                <th>录入时间</th>
                <th>合作学生</th>
              </tr>
            </thead>
            <tbody>
              <?php
                $i = $start ? $start : 1;
                foreach ($res as $value) {
                  echo '<tr>';
                  echo '<td><input type="checkbox" name="sno[]" value="' . $value['sno'] . '"/></td>';
                  echo "<th scope='row'>$i</th>";
                  echo "<td>{$value['sno']}</td>"; 
                  echo "<td>{$value['name']}</td>"; 
                  echo "<td>{$value['title']}</td>"; 
                  echo "<td>{$value['state']}</td>"; 
                  echo "<td>{$value['last_time']}</td>"; 
                  echo "<td>{$value['partner']}</td>"; 
                  echo '</tr>';
                  $i++;
                }
              ?>
            </tbody>
            <?php
              }
            ?>
          </table>
          <nav>
            <ul class="pager">
              <li>
                <?php
                  if($prePage) {
                    if($prePage >= 1) {
                      echo "<a href='index.php?m=Admin&a=adminShow&cur=$prePage'>上一页</a>";
                    }
                  }
                ?>
              </li>
              <li>
                <?php
                  if($nextPage) {
                    if($nextPage >= 1) {
                      echo "<a href='index.php?m=Admin&a=adminShow&cur=$nextPage'>下一页</a>";
                    }
                  }
                ?>
              </li>
            </ul>
          </nav>
          <a href="index.php?m=Admin">返回登陆界面</a>     <input class="btn btn-default" type="submit" value="确认删除"/>
        </form>
      </div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="Public/js/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="Public/js/bootstrap.min.js"></script>
  </body>
</html>

       Application/Admin/View/Index/index.php

  1. <!DOCTYPE html>  
  2. <html lang="zh-CN">  
  3.   <head>  
  4.     <meta charset="utf-8">  
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">  
  6.     <meta name="viewport" content="width=device-width, initial-scale=1">  
  7.     <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->  
  8.     <title>课程设计题目统计后台管理系统</title>  
  9.   
  10.     <!-- Bootstrap -->  
  11.     <link href="Public/css/bootstrap.min.css" rel="stylesheet">  
  12.     <link href="Public/style.css" rel="stylesheet" type="text/css"/>  
  13.   
  14.     <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->  
  15.     <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->  
  16.     <!--[if lt IE 9]>  
  17.       <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>  
  18.       <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>  
  19.     <![endif]-->  
  20.   </head>  
  21.   <body>  
  22.     <div class="container">  
  23.       <div class="col-sm-3"></div>  
  24.       <div class="col-sm-6 content">  
  25.         <h2>课程设计题目统计后台管理系统</h2>  
  26.         <form class="form-horizontal" action="index.php?m=Admin&a=check" method="POST">  
  27.           <div class="form-group">  
  28.             <label for="number" class="col-sm-3 control-label">管理员账号:</label>  
  29.             <div class="col-sm-9">  
  30.               <input type="text" class="form-control" id="number" placeholder="请输入管理员账号" name="account">  
  31.             </div>  
  32.           </div>  
  33.           <div class="form-group">  
  34.             <label for="password" class="col-sm-3 control-label">修改密码:</label>  
  35.             <div class="col-sm-9">  
  36.               <input type="password" class="form-control" id="password" placeholder="请输入管理员密码" name="psw">  
  37.             </div>  
  38.           </div>  
  39.           <div class="form-group">  
  40.             <div class="col-sm-offset-3 col-sm-9">  
  41.               <button type="submit" class="btn btn-info">登陆</button>     
  42.               <a href="index.php?m=Admin&a=show">显示全部学生题目</a>  
  43.             </div>  
  44.           </div>  
  45.           <?php  
  46.             if($err) {  
  47.           ?>  
  48.                <p class="info"><span style="font-weight: bold">错误:</span><?php echo $err;?></p>  
  49.           <?php  
  50.             }  
  51.           ?>  
  52.         </form>  
  53.       </div>  
  54.       <div class="col-sm-3"></div>  
  55.     </div>  
  56.   
  57.     <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->  
  58.     <script src="Public/js/jquery.min.js"></script>  
  59.     <!-- Include all compiled plugins (below), or include individual files as needed -->  
  60.     <script src="Public/js/bootstrap.min.js"></script>  
  61.   </body>  
  62. </html>  
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
    <title>课程设计题目统计后台管理系统</title>

    <!-- Bootstrap -->
    <link href="Public/css/bootstrap.min.css" rel="stylesheet">
    <link href="Public/style.css" rel="stylesheet" type="text/css"/>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <div class="container">
      <div class="col-sm-3"></div>
      <div class="col-sm-6 content">
        <h2>课程设计题目统计后台管理系统</h2>
        <form class="form-horizontal" action="index.php?m=Admin&a=check" method="POST">
          <div class="form-group">
            <label for="number" class="col-sm-3 control-label">管理员账号:</label>
            <div class="col-sm-9">
              <input type="text" class="form-control" id="number" placeholder="请输入管理员账号" name="account">
            </div>
          </div>
          <div class="form-group">
            <label for="password" class="col-sm-3 control-label">修改密码:</label>
            <div class="col-sm-9">
              <input type="password" class="form-control" id="password" placeholder="请输入管理员密码" name="psw">
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-offset-3 col-sm-9">
              <button type="submit" class="btn btn-info">登陆</button>   
              <a href="index.php?m=Admin&a=show">显示全部学生题目</a>
            </div>
          </div>
          <?php
            if($err) {
          ?>
               <p class="info"><span style="font-weight: bold">错误:</span><?php echo $err;?></p>
          <?php
            }
          ?>
        </form>
      </div>
      <div class="col-sm-3"></div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="Public/js/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="Public/js/bootstrap.min.js"></script>
  </body>
</html>
        Application/Admin/View/Index/showStudent.php

  1. <!DOCTYPE html>  
  2. <html lang="zh-CN">  
  3.   <head>  
  4.     <meta charset="utf-8">  
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">  
  6.     <meta name="viewport" content="width=device-width, initial-scale=1">  
  7.     <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->  
  8.     <title>课程设计题目统计系统</title>  
  9.   
  10.     <!-- Bootstrap -->  
  11.     <link href="Public/css/bootstrap.min.css" rel="stylesheet">  
  12.     <link href="Public/style.css" rel="stylesheet" type="text/css"/>  
  13.     <style>  
  14.       p.info {  
  15.         margin-bottom: 0;  
  16.       }  
  17.     </style>  
  18.   
  19.     <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->  
  20.     <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->  
  21.     <!--[if lt IE 9]>  
  22.       <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>  
  23.       <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>  
  24.     <![endif]-->  
  25.   </head>  
  26.   <body>  
  27.     <div class="container">  
  28.       <div class="content">  
  29.         <table class="table table-hover">  
  30.           <caption><h3>学生课程设计题目</h3></caption>  
  31.           <?php  
  32.             if(!isset($res) || empty($res)) {  
  33.               echo '<tr><td>暂无学生题目</td></tr>';  
  34.             } else {  
  35.           ?>  
  36.           <thead>  
  37.             <tr>  
  38.               <!-- <th>删除</th> -->  
  39.               <th>序号</th>  
  40.               <th>学号</th>  
  41.               <th>姓名</th>  
  42.               <th>题目</th>  
  43.               <th>状态</th>  
  44.               <th>录入时间</th>  
  45.               <th>合作学生</th>  
  46.             </tr>  
  47.           </thead>  
  48.           <tbody>  
  49.             <?php  
  50.               $i = $start ? $start : 1;  
  51.               foreach ($res as $value) {  
  52.                 echo '<tr>';  
  53.                 echo "<th scope='row'>$i</th>";  
  54.                 echo "<td>{$value['sno']}</td>";   
  55.                 echo "<td>{$value['name']}</td>";   
  56.                 echo "<td>{$value['title']}</td>";   
  57.                 echo "<td>{$value['state']}</td>";   
  58.                 echo "<td>{$value['last_time']}</td>";   
  59.                 echo "<td>{$value['partner']}</td>";   
  60.                 echo '</tr>';  
  61.                 $i++;  
  62.               }  
  63.             ?>  
  64.           </tbody>  
  65.           <?php  
  66.             }  
  67.           ?>  
  68.         </table>  
  69.         <nav>  
  70.           <ul class="pager">  
  71.             <li>  
  72.               <?php  
  73.                 if($prePage) {  
  74.                   if($prePage >= 1) {  
  75.                     echo "<a href='index.php?m=Admin&a=show&cur=$prePage'>上一页</a>";  
  76.                   }  
  77.                 }  
  78.               ?>  
  79.             </li>  
  80.             <li>  
  81.               <?php  
  82.                 if($nextPage) {  
  83.                   if($nextPage >= 1) {  
  84.                     echo "<a href='index.php?m=Admin&a=show&cur=$nextPage'>下一页</a>";  
  85.                   }  
  86.                 }  
  87.               ?>  
  88.             </li>  
  89.           </ul>  
  90.         </nav>  
  91.         <a href="index.php?m=Admin">返回登陆界面</a>  
  92.       </div>  
  93.     </div>  
  94.   
  95.     <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->  
  96.     <script src="Public/js/jquery.min.js"></script>  
  97.     <!-- Include all compiled plugins (below), or include individual files as needed -->  
  98.     <script src="Public/js/bootstrap.min.js"></script>  
  99.   </body>  
  100. </html>  
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
    <title>课程设计题目统计系统</title>

    <!-- Bootstrap -->
    <link href="Public/css/bootstrap.min.css" rel="stylesheet">
    <link href="Public/style.css" rel="stylesheet" type="text/css"/>
    <style>
      p.info {
        margin-bottom: 0;
      }
    </style>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
	<div class="container">
      <div class="content">
        <table class="table table-hover">
          <caption><h3>学生课程设计题目</h3></caption>
          <?php
            if(!isset($res) || empty($res)) {
              echo '<tr><td>暂无学生题目</td></tr>';
            } else {
          ?>
          <thead>
            <tr>
              <!-- <th>删除</th> -->
              <th>序号</th>
              <th>学号</th>
              <th>姓名</th>
              <th>题目</th>
              <th>状态</th>
              <th>录入时间</th>
              <th>合作学生</th>
            </tr>
          </thead>
          <tbody>
            <?php
              $i = $start ? $start : 1;
              foreach ($res as $value) {
                echo '<tr>';
                echo "<th scope='row'>$i</th>";
                echo "<td>{$value['sno']}</td>"; 
                echo "<td>{$value['name']}</td>"; 
                echo "<td>{$value['title']}</td>"; 
                echo "<td>{$value['state']}</td>"; 
                echo "<td>{$value['last_time']}</td>"; 
                echo "<td>{$value['partner']}</td>"; 
                echo '</tr>';
                $i++;
              }
            ?>
          </tbody>
          <?php
            }
          ?>
        </table>
        <nav>
          <ul class="pager">
            <li>
              <?php
                if($prePage) {
                  if($prePage >= 1) {
                    echo "<a href='index.php?m=Admin&a=show&cur=$prePage'>上一页</a>";
                  }
                }
              ?>
            </li>
            <li>
              <?php
                if($nextPage) {
                  if($nextPage >= 1) {
                    echo "<a href='index.php?m=Admin&a=show&cur=$nextPage'>下一页</a>";
                  }
                }
              ?>
            </li>
          </ul>
        </nav>
        <a href="index.php?m=Admin">返回登陆界面</a>
      </div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="Public/js/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="Public/js/bootstrap.min.js"></script>
  </body>
</html>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值