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

📄 mng_stu_edit.php

📁 在实际教学应用中
💻 PHP
字号:
<?php session_start(); if(!$_SESSION['teacher']) {echo '<SCRIPT LANGUAGE="JavaScript">location.replace(\'mng.php\');</script>';exit;}?>
<html>
<head>
<title>EasyTeacher信息技术课堂教学助手(ItAssis)-学生管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="et.css" rel="stylesheet" type="text/css">
<style type="text/css">body,td,th {font-size: 14px;}</style>
</head>
<body>
<?php
	include "conn.inc.php";
	include "ItAssisFC/FLib.php";
	include "config.inc.php";
	$db=Connect_db($CFG_DB_ADDRESS,$CFG_DB_PORT,$CFG_DB_NAME,$CFG_DB_OWNER,$CFG_DB_PWD);

	if(isset($_POST['sid'])) $sid=$_POST['sid'];
	if(isset($_GET['sid'])) $sid=$_GET['sid'];
		
	//输入检查
	//字符长度检查
	//team数量不的少于班级的一半人数字
    if ( isset($_POST['action']) && $_POST['action']=="修改" ){

		list($grade,$class)=split(",",$_POST['grade_class']);

		if(!$_POST['team']) $team="NULL";else $team=$_POST['team'];
		$identity=$_POST['identity']; //默认身份为学生

		$sql ="UPDATE stu ";
        $sql.="SET pwd=\"".$_POST['pwd']."\",";
   	    $sql.="grade=$grade,";
        $sql.="class=$class,";
        $sql.="sex=\"".$_POST['sex']."\",";
   	    $sql.="team=$team,";
        $sql.="seat=\"".$_POST['seat']."\",";
   	    $sql.="identity=$identity";
       	$sql.=" WHERE sid=\"$sid\"";
		mysql_query($sql,$db) or die("<b>$sql</b><br>" . mysql_error());

		echo "<p align=center><span class=red>“ $sid ”资料修改成功!</span></p>";
		Refresh_parent_page();
	}//修改学生资料结束

	if(isset($_POST['action']) && $_POST['action']=="删除"){
		//查找并删除学生照片
		$sid=$_POST['sid'];
		$sql ="SELECT pic FROM stu WHERE sid=\"$sid\"";
		$result=mysql_query($sql,$db) or die("<b>$sql</b><br>" . mysql_error());
		$array=mysql_fetch_array($result);
		$file_name="$CFG_STU_PHOTO_DIR/".$array['pic'];
		if(is_file($file_name))	unlink($file_name);

		//删除作业表中作业记录,同时删除作业文件
		$sql ="SELECT tid,crs_id,nfname FROM task,s_c_t";
		$sql.=" WHERE tsk_id=tid and stu_id=\"$sid\"";
		$result=mysql_query($sql,$db) or die("<b>$sql</b><br>" . mysql_error());

		$tid_list=array(mysql_fetch_row($result));
		while($data=mysql_fetch_row($result))
			array_push($tid_list,$data);
		while(list($tid,$crs_id,$nfname)=array_shift($tid_list)){
			chdir("$CFG_TASK_DIR/$crs_id/");
			if(is_file($nfname)) 
				if(!unlink($nfname)){echo "$nfname 删除失败!";exit;}
			else 
				{echo "$nfname 不是文件,作业删除失败!删除用户失败!<br>";exit;}
				
			$sql ="DELETE FROM task WHERE tid=$tid";		
			mysql_query($sql,$db) or die("<b>$sql</b><br>" . mysql_error());
		}

		//删除学生-课程-作业中记录 关联表中关联记录
		$sql ="DELETE FROM s_c_t ";
		$sql.="WHERE stu_id=\"$sid\"";		
		mysql_query($sql,$db) or die("<b>$sql</b><br>" . mysql_error());

		//删除课堂表现中记录
		$sql ="DELETE FROM express WHERE stu_id=\"$sid\"";
		mysql_query($sql,$db) or die("<b>$sql</b><br>" . mysql_error());

		//删除学生档案中学生记录
		$sql ="DELETE FROM stu WHERE sid=\"$sid\"";
		mysql_query($sql,$db) or die("<b>$sql</b><br>" . mysql_error());

		echo "<p align=center><span class=red>报告:学生“ $sid ”及其所有相关记录已被删除!</span></p>";
		Auto_close_page(3);
		Refresh_parent_page();
		exit;
    }//删除学生结束

	$sql ='SELECT * FROM stu';
	$sql.=' WHERE sid="'.$_GET['sid']."\"";
	$result = mysql_query($sql,$db) or die("<b>$sql</b><br>" . mysql_error());

	$stu=mysql_fetch_array($result);
	if(!$stu['pic']) $stu['pic']="none.jpg";
?>
<form name="form1" method="post" action="">
  <table width="391" border="1" align="center" cellpadding="2" cellspacing="1" bordercolor="#B5C7D6">
    <tr>
      <td width="119" rowspan="10" bgcolor="#FFCC99"><p align="center"><a href="<?php echo "$CFG_STU_PHOTO_DIR/".$stu['pic'];?>"><img src="<?php echo "$CFG_STU_PHOTO_DIR/".$stu['pic'];?>" width="100" height="120" border="0" align="absbottom"></a><br>
      (点击看大图)      </p></td>
    </tr>
    <tr>
      <td width="127" height="24" bgcolor="#C6CFDE"><p>ID号:<span class="red"><?php echo $stu['sid'];?></span></p>
      </td>
      <td width="127" bgcolor="#C6CFDE">姓名:<span class="red"><?php echo $stu['sname'];?></span></td>
    </tr>
    <tr>
      <td height="28" colspan="2" bgcolor="#C6CFDE"><p>密码:
            <input name="pwd" type="text" size="10" value="<?php echo $stu['pwd'];?>">
      </p>
      </td>
    </tr>
    <tr>
      <td height="14" colspan="2" bgcolor="#C6CFDE">性别:
        <select name="sex" id="sex">
          <option value="<?php echo $stu['sex'];?>"><?php echo $stu['sex'];?></option>
          <option value="男">男</option>
          <option value="女">女</option>
        </select></td>
    </tr>
    <tr>
      <td height="15" colspan="2" bgcolor="#C6CFDE">年级:
        <select name="grade_class" >
          <option value="<?php echo $stu['grade'].",".$stu['class'];?>"> <?php echo $stu['grade']."(".$stu['class'].")";?></option>
          <?php 	for($i=$CFG_USER_START_GRADE;$i<=$CFG_USER_END_GRADE;$i++)
			for($j=1;$j<=$CFG_USER_MAX_CLASS;$j++)
				echo "<option value=$i,$j> $i($j)班 </option>";
?>
        </select></td>
    </tr>
    <tr>
      <td height="28" colspan="2" bgcolor="#C6CFDE">分组:
              <select name="team">
			  <option value="<?php echo $stu['team'];?>"><?php if($stu['team'])echo "第 ".$stu['team']." 组";else echo "未分组";?></option>
			<?php for($j=1;$j<=$CFG_STU_MAX_TEAM_NUM;$j++) 
						echo "<option value=\"$j\">第 $j 组</option>";?>
            </select>
        <span class="red"> </span></td>
    </tr>
    <tr>
      <td height="28" colspan="2" bgcolor="#C6CFDE">座位:
        <input name="seat" type="text" size="6" value="<?php echo $stu['seat'];?>">
        <span class="red">(不超过10个字符)</span></td>
    </tr>
    <tr>
      <td height="14" colspan="2" bgcolor="#C6CFDE">职务:
        <select name="identity">
          <option value="<?php echo $stu['identity'];?>"><?php echo $STU_TYPE[$stu['identity']];?></option>
          <option value="2">学生</option>
          <option value="1">组长</option>
          <option value="0">课代表</option>
        </select></td>
    </tr>
    <tr>
      <td height="7" colspan="2" bgcolor="#C6CFDE">积分:<?php echo $stu['score']?></td>
    </tr>
    <tr>
      <td height="7" colspan="2" bgcolor="#C6CFDE">注册时间:<?php echo Split_datatime($stu['reg_time']);?></td>
    </tr>
  </table>
  <p align="center">
    <input type="Submit" name="action" value="修改">
    <input type="Submit" name="action" value="删除" <?php if($CFG_STU_DELETE_AOLLOWED) echo "disabled"; ?>>
    <input type=button value="关闭" onClick="javascript:self.close();">
    <input name="sid" type="hidden" value="<?php echo $stu['sid'];?>">
  </p>
</form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -