您的位置:首页 > 数据库

一个用隐藏域修删除数据库记录的代码

2006-07-30 20:15 381 查看
前台文件:

<!--#include file="../conn/conn.asp"-->

<table   border="1"   cellspacing=1  align="center"   width="92%">  
      <tr   CLASS=TR1>    
          <td   align="center"   class=td2><font   color="#000000">操作</font></td>
          <td   align="center"   class=td2><font   color="#000000">题目编号</font></td>  
          <td   align="center"   class=td2><font   color="#000000">题目标题</font></td>  
          <td   align="center"   class=td2><font   color="#000000">指导老师</font></td>  
          <td   align="center"   class=td2><font   color="#000000">课题性质</font></td>  
          <td   align="center"   class=td2><font   color="#000000">教研室</font></td> 
          <td   align="center"   class=td2><font   color="#000000">是否审核</font></td>
          <td   align="center"   class=td2><font   color="#000000">是否以选</font></td>
          <td   align="center"   class=td2><font   color="#000000">备注</font></td> 
      </tr>  
      <%     on   error   resume   next  
              Set   RS   =   Server.CreateObject("ADODB.Recordset")  
              strSql   =   "SELECT   *   FROM  topic"  
              RS.OPEN   strSql,CONN,1  
            do   while   not   rs.eof  
      %>  
      <tr>
 
            <td align="center"   height="19"><form id="form1" name="form1" method="post" action="topic_del.asp">
  <input type="hidden" name="hiddenField"  value="<%=trim(rs("topic_no"))%>">
  <input type="submit" name="Submit" value="删除" onclick="{if(confirm('您确定要删除此题目吗?')){return true;}return false;}">
</form></td>
          <td   align="center"   height="19"><%=trim(rs("topic_no"))%></td>  
           <td   align="center"   height="19"><%=trim(rs("topic_name"))%></td>
            <td   align="center"   height="19"><%=trim(rs("topic_tch_name"))%></td>
          <td   align="center"   height="19"><%=trim(rs("topic_prop"))%> </td>  
          <td   align="center"   height="19"><%=trim(rs("topic_jys"))%> </td>  
          <td   align="center"   height="19"><%=trim(rs("topic_pass"))%> </td>  
          <td   align="center"   height="19"><%=trim(rs("topic_flag"))%> </td> 
          <td   align="center"   height="19"><%=trim(rs("topic_memo"))%> </td> 
      </tr>  
      <% rs.movenext  
  loop    
                    rs.close  
                    set   rs  = nothing  
   
    %>

<%
rs.close
Set rs = Nothing
conn.close
set conn=Nothing
%>

 后台处理文件

<!--#include file="../conn/conn.asp"-->

<%
id=request("hiddenField")
SqlStr = "delete from topic where topic_no=" & id
Conn.Execute(SqlStr)
response.write"<script>alert('已经成功删除!');location='topic_view.asp'</script>"
%>

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐