Forum Moderators: open

Message Too Old, No Replies

ASP code doing my head in

insert multiple records from a loop

         

gingerbreadman

6:11 am on Apr 16, 2003 (gmt 0)

10+ Year Member



Can anyone help me with a little piece of code that is doing my head in.

I am creating a report generator. It is really just a big poll.

I have created a loop to pull records out of a database. These records are questions with radio buttons 'yes/no' answers.

I then need to be able to add the results in to a table.

Someone has told me that I need to work out the number of records coming out of the database so that I can then work out how many inserts to do.

Anyone out there who could help?

cheers
Ross

jimmykav

7:56 am on Apr 16, 2003 (gmt 0)

10+ Year Member



you do not need to know number of records in advance. assuming rs is a recordset then the psuedo code might look like this

write "<table>"

do while not rs.eof
write "<tr>"

write "<td>"
write rs("field0")
write "</td>"

write "<td>"
write rs("field1")
write "</td>"

write "</tr>"
loop

write "</table>"

Dreamquick

7:58 am on Apr 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need a movenext in there too, otherwise its an infinite loop...


write "<table>"

do while not rs.eof
write "<tr>"
write "<td>" & rs("field0").value & "</td>"
write "<td>" & rs("field1").value & "</td>"
write "</tr>"
rs.movenext
loop

write "</table>"

gingerbreadman

9:05 am on Apr 16, 2003 (gmt 0)

10+ Year Member



Thanks for the help.

After reading my post again, I'm sorry I didn't explain my self properly.

I then need to be able to add the results in to a table.

Should have said.. I then need to be able to add the answers (from the selected radio buttons) in to a database table.

I've got the list of questions looping from the database but I'm struggling with handling the answers inserting in to the 'answers' database table.

jimmykav

9:07 am on Apr 16, 2003 (gmt 0)

10+ Year Member



Oopps Dreamquick! ;) silly me.