循环删除的问题,我脑子都转不过来圈了,求助~

songqihao 2006-04-12 05:45:27
用户表(usertable):user(用户名字段)
文章表(news):aid(自动编号),user(该用户),image(文章中上传的图片)
文章生成的html:html/<%=rs("aid")%>.htm
文章中上传的图在:uppic/下,文件名<%=rs("images")%>

要求:在checkbox多选批量删除用户(user)的同时,删除该用户在(news)表中所有记录,同时删除每条记录对应的html文件和image文件
...全文
131 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
songqihao 2006-04-14
  • 打赏
  • 举报
回复
经测试发现可以删除单条纪录,多条不可以,循环那里有问题么?我看不出来!
yuanxiaolei 2006-04-14
  • 打赏
  • 举报
回复
呵呵。看看我的新闻系统吧。

漂移新闻系统v1.0

只售300元!

此新闻系统具有以下功能:

1、添加新闻自动生成htm新闻文件。

2、可以修改新闻,修改后并自动生成htm新闻文件。(利于百度搜索)

3、可将所有数据库中新闻生成htm新闻文件。(批量生成)

4、新闻显示顺序可以自行设定。

5、在删除数据库中新闻的同时,可以删除自动生成htm的新闻文件。(节省空间)

6、具有批量删除新闻功能。

7、生成的htm新闻具有自动分页功能。(文章内容过长分几页显示)

漂移网络新闻系统:http://www.cnzzy.cn/Info/24.aspx


前台演示地址:http://www.piaoy.cn/spcs/pyxw/cjwt.asp

后台登录演示地址:http://www.piaoy.cn/spcs/pyxw/piaoy/index.htm

登录名和登录密码:piaoy

联系方式:MSN/Email:yuanxiaolei8698@163.com



只售300元!

songqihao 2006-04-14
  • 打赏
  • 举报
回复
原来是in函数的问题,改成where instr(1,'"&theid&"',uid)>0"就好了,但是为什么in不行呢?不管怎么说,问题解决了,万分感谢两位朋友!给分解铁!
songqihao 2006-04-14
  • 打赏
  • 举报
回复
以下是我完整的代码,请帮忙看看,为什么不能循环删除,只能单个删除?
----------------------------------
sql="select adid,pic from data where uid in ('"&request("adid")&"')"
set rs=conn.execute(sql)
while not rs.eof
'in('"&replace(request("adid")&"')"
Set Fso=Server.Createobject("Scripting.FileSystemObject")
if fso.FileExists(server.mappath("../html/"&rs("adid")&".htm")) Then
Fso.DeleteFile(server.mappath("../html/"&rs("adid")&".htm"))
end if
if rs("pic")<>"" and fso.FileExists(server.mappath("../adpic/"&rs("pic")))then
Fso.DeleteFile(server.mappath("../adpic/"&rs("pic")))
end if
set fso=nothing

rs.movenext
wend
rs.close
sql="delete from user where uid in ('"&request("adid")&"')"
conn.execute(sql)
sql="delete from data where uid in ('"&request("adid")&"')"
conn.execute(sql)
码到末日 2006-04-13
  • 打赏
  • 举报
回复
mark
songqihao 2006-04-13
  • 打赏
  • 举报
回复
首先感谢!!!
但是怎么不行啊,两个朋友的代码我都用了,不行啊,出错`
风行的in('"&replace(request("username")&"')"这句怎么觉得不太对阿,替换的什么啊?
请教一下啊~
ybcola 2006-04-12
  • 打赏
  • 举报
回复
function filedel(filepath)
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.fileexists(Server.mappath(filepath)) then
fso.DeleteFile(Server.mappath(filepath)) )
end if
Set fso = nothing
end functin
haode_qu 2006-04-12
  • 打赏
  • 举报
回复
偶菜鸟一只,是来踩肢印的
songqihao 2006-04-12
  • 打赏
  • 举报
回复
谢谢,我回去试试,可以就加分!再次感谢 啊~
subasan 2006-04-12
  • 打赏
  • 举报
回复
楼上的楼上的比我周到。。可是没有对文件进行操作,光删除了数据库里的~
subasan 2006-04-12
  • 打赏
  • 举报
回复
竟然有人出脚比我还快。厉害
subasan 2006-04-12
  • 打赏
  • 举报
回复
for each pc in request.form("pc")
set ts=conn.execute("select img,htm from table where id="&pc)
if not (ts.eof and ts.bof) then
'得到图片路径
'得到htm路径
conn.execute("delete from table where id="&pc)

Set fso = CreateObject("Scripting.FileSystemObject")
if fso.fileexists(Server.mappath(filepath)) then
fso.DeleteFile(Server.mappath(图片))
fso.DeleteFile(Server.mappath(htm))
end if
Set fso = nothing
end if
ts.close
set ts=nothing
end if
next
ybcola 2006-04-12
  • 打赏
  • 举报
回复
用户表(usertable):user(用户名字段)
文章表(news):aid(自动编号),user(该用户),image(文章中上传的图片)
文章生成的html:html/<%=rs("aid")%>.htm
文章中上传的图在:uppic/下,文件名<%=rs("images")%>

sql="select aid,images from news where user in('"&replace(request("username")&"')"
set rs=conn.execute(sql)
while not rs.eof
filedel("html/"+rs("aid")+".htm")
filedel("uppic/"+rs("images"))
rs.movenext
wend
rs.close
sql="delete * from news where user in('"&replace(request("username")&"')"
conn.execute(sql)
sql="delete * from usertable where user in('"&replace(request("username")&"')"
conn.execute(sql)

28,408

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧