日期:2014-05-20 浏览次数:20681 次
<html> <head> </head> <body> <h2 align="center">你准备修改的学生的成绩是:</h2> <table align="center" width="80%" border="1"> <tr> <td align="center">学号</td> <td align="center">语文成绩</td> <td align="center">数学成绩</td> <td align="center">英语成绩</td> <td align="center">计算机成绩</td> </tr> <tr><td align="center">333</td> <td align="center">60</td> <td align="center">58</td> <td align="center">74</td> <td align="center">49</td> </table> <h2> 输入新值:</h2><br/> <form action="change.jsp"> <table align="center" width="80%" border="1" height="77" > <tr> <td align="center">语文成绩</td> <td align="center">数学成绩</td> <td align="center">英语成绩</td> <td align="center">计算机成绩</td> </tr> <tr> <td align="center"><input type="text" name="chinese" /></td><td align="center"><input type="text" name="math"/></td><td align="center"><input type="text" name="english"/></td><td align="center"><input type="text" name="computer"/></td> </tr> </table><br/> <div align="center"> <input type="submit"value="提交修改" ></div> </form> </body> </html>
DBHelper db=new DBHelper(); String ids= (String)session.getAttribute("id"); String[] s={"chinese","math","english","computer"}; for(int i=0;i<s.length;i++) { if(request.getParameter(s[i])!=null){ String ss=request.getParameter(s[i]); if(ss!=null ) { int fe=Integer.parseInt(ss); String sql="update grade set "+s[i]+"="+fe+" where id="+ids; db.exeUpdate(sql); out.print("<script>alert('修改成功')</script>"); } } } %> </body>