<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<body>
<div id="formbackground" style="position:absolute; width:100%; height:45%; z-index:-1"><img src="head.png" width="100%" height="45%" /></div>
<br><br><br>
                                    
                                    
                                    
                                    
                                    
                       
<?php
session_start();
echo $_SESSION['Student_Name'];
?>
<?php
// session_start();
header("Content-Type:text/html;charset=gbk");
$link0="链 接 :";
$link00=iconv("UTF-8","gbk",$link0);
echo "<br><br><br><br><br>    $link00";
$link1="综合考评细则";
$link11=iconv("UTF-8","gbk",$link1);
echo "         <a href='/school/studentA/detail/detail1.html' style='text-decoration:none'>$link11</a>";
$link2="德育考评细则";
$link22=iconv("UTF-8","gbk",$link2);
echo "        <a href='/school/studentA/detail/detail2.html' style='text-decoration:none'>$link22</a>";
$link3="额外加分细则";
$link33=iconv("UTF-8","gbk",$link2);
echo "        <a href='/school/studentA/detail/detail3.html' style='text-decoration:none'>$link33</a>";
?>
<div style="margin-left:0px; margin-top:20px; width:30px; height:30px;"><a href="/school/studentA/apply/apply.php"><img src="1.png"></a></div>
<div style="margin-left:0px; margin-top:75px; width:30px; height:30px;"><img src="2.png"></a></div>
<div style="margin-left:0px; margin-top:70px; width:30px; height:30px;"><a href="/school/studentA/moral/moral.php"><img src="3.png"></a></div>
<div style="margin-left:0px; margin-top:70px; width:30px; height:30px;"><a href="/school/studentA/sum/sum.php"><img src="4.png"></a></div>
<div style="margin-left:0px; margin-top:70px; width:30px; height:30px;"><a href="/school/studentA/exam/exam.php"><img src="5.png"></a></div>
<form action="1150.php" method="post">
<table style="margin-left:304px;margin-top:-480px;" border=1 bordercolor="#6E6E6E" cellpadding="15" frame="box" rules="all">
<br><br>
<?php
header("Content-Type: text/html;charset=gbk");
$con=mysql_connect("localhost","root","9277");
mysql_select_db("School",$con);
mysql_query("set names 'gbk'");
$i=0;
$verifyClass=$_SESSION['Student_Class'];
$result=mysql_query("SELECT * FROM `Add`where Class='$verifyClass'");//mysql_query 查询数据库的函数
$hd=$_SESSION["Student_Class"];
$hf=mysql_query("select count(*) from `Add`where Class='$hd'");
while($num=mysql_fetch_array($hf)){
$_SESSION["Addnum"]=$num[0];
}
$status1="比赛名称";$status11=iconv("UTF-8","gbk",$status1);
$status2="获得奖项";$status22=iconv("UTF-8","gbk",$status2);
$status3="加分";$status33=iconv("UTF-8","gbk",$status3);
$status4="比赛说明";$status44=iconv("UTF-8","gbk",$status4);
echo "<tr align=\"center\" bgcolor=\"#F7F7F7\">
<td style=\"width:150px;\">Class</td><td style=\"width:150px;\">Name</td><td style=\"width:150px;\">ID</td>
<td style=\"width:150px;\">$status11</td><td style=\"width:250px;\">$status22</td><td>$status33</td><td style=\"width:300px;\">$status44</td>
</tr>";
while($row=mysql_fetch_array($result)){
$i=$i+1;
if($i%2==1){
echo "<tr align=\"center\">
<td>$row[2]</td><td>$row[0]</td><td>$row[1]</td>
<td>$row[3]</td> <td>$row[4]</td>
<td><input type=\"text\" name=add$i /></td> <td>$row[6]</td>
</tr>";
$_SESSION["ID_Add".$i]=$row[1];
}else{
echo "<tr bgcolor=\"#DCDCDC\" align=\"center\">
<td>$row[2]</td><td>$row[0]</td><td>$row[1]</td>
<td>$row[3]</td><td>$row[4]</td>
<td><input type=\"text\" name=add$i /></td> <td>$row[6]</td>
</tr>";
$_SESSION["ID_Add".$i]=$row[1];
}
}
?>
</table>
<table style="margin-left:1750px;margin-top:0px;">
<tr><br><br>
<?php
echo "<td><input type=\"submit\" name=\"submitadd\" value=\"submit\"></td>";
?>
</tr>
</table>
</form>
</body>
</html>
后台处理
<?php
session_start();
header("Content-Type:text/html;charset=gbk");
$i=1;
$numa=$_SESSION["Addnum"];
while($i<=$numa){
if(isset($_POST["submitadd"])&&$_POST["submitadd"] =="submit"){
$str1= $_POST["add".$i];
if($_POST["add".$i]==""){
echo "<script LANGUAGE='javascript'>alert('content should be null'); history.go(-1);</script>";
}else if($_POST["add".$i]>20.00001||$_POST["add".$i]<0){
echo "<script LANGUAGE='javascript'>alert('content is illegal'); history.go(-1);</script>";
}else{
$con=mysql_connect("localhost","root","9277");
mysql_select_db("School",$con);
mysql_query("set names 'gbk'");
$ID= $_SESSION["ID_Add".$i];
$sql="UPDATE `Add` SET `add`=\"$str1\" WHERE ID=\"$ID\"";
$result=mysql_query($sql);
}
}
$i++;
}
echo "<script LANGUAGE='javascript'>alert('sucecessfully'); history.go(-1);</script>"; //弹出提示框返回上一
?>