Quote:
Originally posted by austin322
I have a list of records in the database on one of my pages. I have it setup, were you have to delete each record manually. I would like to add a checkbox beside the records, and a button to delete checked items, but when I set it up, when I checked some of the records the code I was using only delted the first record that I checked. Here is the code that I used:
Please Help!
|
No problem!
little sample script to display delete form
--------------------------------------
<%
response.write "<form method=post action=delete.asp>"
sql = "select id, name from scores order by id desc"
rs.open sql, conn,3,3
do while not rs.eof
response.write "<input type=checkbox name=score value=" & rs("id") & ">" & rs("name")
rs.movenext
loop
response.write "</form>"
%>
script to delete (delete.asp)
---------------------------------------
<%
sql="delete from scores where id in (" & request("score") & ")"
conn.Execute sql,,adCmdText + adExecuteNoRecords
%>
This works definitly with MSSQL and should also work with Access or mySQL. Test it.
Jenny