投票系统

思路篇

2008-08-05 17:34

表1  

id        bt         dd       kg                   ID   标题 单选/多选 是/否关闭

表2

id      fuid      vote   count    color      ID    父ID   小选项 数量 颜色样式

增加---------
首先加入投票标题

conn.execute("insert into class (bt,dd,kg) values ('"&title&"','"&dd&"',0)")
set rs=server.createobject("adodb.recordset")
然后取得起ID号码
sql="select top 1 * from class where title='"&title&"' order by id desc"
rs.open sql,conn,1,1
classid=rs("id")
rs.close
set rs=nothing
然后循环加入小选项
for i=1 to request("t").count
if request("t")(i)<>"" then
conn.execute("insert into vote (vote,color,fuid) values ('"&request("t")(i)&"','"&request("color")(i)&"',"&classid&")")
else
exit for
end if
next
response.write "<script>alert('添加投票成功');</script>"
response.write "<script>location.href='step1.asp';</script>"
conn.close
set conn=nothing

删除----------
取得起大类的ID号
conn.execute("delete from 表2 where ufid=id") '清除小类
conn.execute("delete from 表1 where id=id")    '清除大类
response.write "<script>alert('删除投票成功');</script>"
response.write "<script>location.href='votelist.asp';</script>"

修改----------