|
 |
asp_databases thread: R: SV: R: Re: FOR....LOOP
Message #1 by "Giovanni Salucci" <g.salucci@n...> on Sat, 16 Feb 2002 15:49:41 +0100
|
|
the SQL must insert only 5 fields at a time...
i design the db in order to let user complete the answers
or modify them... but your suggestion is good too!
-----Messaggio originale-----
Da: Håkan Frennesson [mailto:hakan@c...]
Inviato: sabato 16 febbraio 2002 15.31
A: ASP Databases
Oggetto: [asp_databases] SV: R: Re: FOR....LOOP
Hi!
Just one thought about table design:
I would to this (for practical reasons)
tbl_answers only needs a few fields and makes it easier to handle during
insert:
UserID
QuestionID
Answer
That way each page inserts 5 answers=5 records rather than creating one
record at the beginning and updating for every question page....unless you
want to give the user a possibility to change an answer allready given, then
I am in deep **** ;-)
Just the thought of making SQL statement with some 100 fields makes me
tremble :-)
Hakan
-----Ursprungligt meddelande-----
Från: Giovanni Salucci [mailto:g.salucci@n...]
Skickat: den 16 februari 2002 15:07
Till: ASP Databases
Ämne: [asp_databases] R: Re: FOR....LOOP
assuming you are using a database (access or sqlserver) the schema may be:
THE DATABASE
table questions (you store questions)
id_question (int)
question (text or memo)
table user (you store here the registration of users)
iduser (int autonumber)
user (text) you store name and surname
table answers
idrecord (int autonumber)
iduser (int) related with user table
ans01 (text)
ans02 (text)
....
ans100 (text)
ASP files
you need only some files:
1) form registration, in which you ask for user data and pass data to
regisytration.asp
2) registration.asp which validate user data and insert them in database,
then redirect to questionpage
3) question form display 5 questions of database. to control which answer
display you might use a Session variable
or use querystring. Submitting the form redirect to insert.asp
4) insert.asp validate the answers, insert them in table answers, then
redirect to question.asp for next displaying
or to final page when all questions are displayed
5) final page: you need thanks user to answering lot of pages!!!
remember you need pass from a page to another the iduser to update the
record...
HTH
Giovanni
-----Messaggio originale-----
Da: Linday Bakharia [mailto:lindsay_bakharia@h...]
Inviato: sabato 16 febbraio 2002 13.50
A: ASP Databases
Oggetto: [asp_databases] Re: FOR....LOOP
Sorry my message wasn't clear enough. My goal is to display 5 questions
on each page and have a NEXT button at the end of each page to allow the
user to go to the next page until all the questions are addressed.
> Hi,
>
> I am building a data driven Survey application. It's a long survey (100
> questions) and I would like to display 5 questions on each page. I was
> sucessfully written a page that could display all the questions and
values
> on the web. I know a For....Loop would do it but since I am new to
asp,
> it's like a pain in neck.
>
> I would appreciate if you can give me a line of code or a site where I
can
> learn how to do this.
>
>
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
Message #2 by "Linday Bakharia" <lindsay_bakharia@h...> on Sat, 16 Feb 2002 16:10:00
|
|
Thanks for a quick response. However, I don't think I state my question
clearly. Here it goes again....
I have already created 2 tables in SQL server (question and answer tables)
question table has 2 fieldnames
id (unique)
question (varchar)
answer table has 4 fieldnames
id (unique)
questionid
description
total
Question table
id question
1 what language are you using to build your application?
2 How long would it take?
Answer table
id questionid description total
1 1 ASP 0
2 1 CF 0
3 1 PHP 0
4 2 Lotus Notes 0
5 2 Perl 0
6 2 Java 0
*************************
Code sample
*************************
<%
.....
SQL = "SELECT * from question order by id desc"
rs.open sql,conn
do while not rs.eof
queID = rs("ID")
sql1 = "select * from answer where questionID="&questionID
response.write "<b>" & rs("question") & "</b><br>"
response.write "<input type='hidden' name='questionID'
value="&questionID&">"
set rs1=conn.execute(sql1)
do while not rs1.eof
response.write "<input type=radio name=poll"&questionID
& " value='"&rs1("id")&"'>"&rs1("desccription") & "<br>"
rs1.movenext
loop
rs.movenext
loop
%>
..........
Right now, if I view this page, I would have a long page with a 100
questions on it.
My question is: How should I break it down say like 5 questions on each
page instead of a 100?
> the SQL must insert only 5 fields at a time...
> i design the db in order to let user complete the answers
> or modify them... but your suggestion is good too!
>
>
> -----Messaggio originale-----
> Da: Håkan Frennesson [mailto:hakan@c...]
> Inviato: sabato 16 febbraio 2002 15.31
> A: ASP Databases
> Oggetto: [asp_databases] SV: R: Re: FOR....LOOP
>
>
> Hi!
>
> Just one thought about table design:
> I would to this (for practical reasons)
> tbl_answers only needs a few fields and makes it easier to handle during
> insert:
>
> UserID
> QuestionID
> Answer
>
> That way each page inserts 5 answers=5 records rather than creating one
> record at the beginning and updating for every question page....unless
you
> want to give the user a possibility to change an answer allready given,
then
> I am in deep **** ;-)
>
> Just the thought of making SQL statement with some 100 fields makes me
> tremble :-)
>
> Hakan
>
> -----Ursprungligt meddelande-----
> Från: Giovanni Salucci [mailto:g.salucci@n...]
> Skickat: den 16 februari 2002 15:07
> Till: ASP Databases
> Ämne: [asp_databases] R: Re: FOR....LOOP
>
>
> assuming you are using a database (access or sqlserver) the schema may
be:
>
> THE DATABASE
>
> table questions (you store questions)
> id_question (int)
> question (text or memo)
>
> table user (you store here the registration of users)
> iduser (int autonumber)
> user (text) you store name and surname
>
>
> table answers
> idrecord (int autonumber)
> iduser (int) related with user table
> ans01 (text)
> ans02 (text)
> ....
> ans100 (text)
>
>
>
> ASP files
>
> you need only some files:
> 1) form registration, in which you ask for user data and pass data to
> regisytration.asp
> 2) registration.asp which validate user data and insert them in database,
> then redirect to questionpage
> 3) question form display 5 questions of database. to control which answer
> display you might use a Session variable
> or use querystring. Submitting the form redirect to insert.asp
> 4) insert.asp validate the answers, insert them in table answers, then
> redirect to question.asp for next displaying
> or to final page when all questions are displayed
> 5) final page: you need thanks user to answering lot of pages!!!
>
> remember you need pass from a page to another the iduser to update the
> record...
>
> HTH
>
> Giovanni
>
>
> -----Messaggio originale-----
> Da: Linday Bakharia [mailto:lindsay_bakharia@h...]
> Inviato: sabato 16 febbraio 2002 13.50
> A: ASP Databases
> Oggetto: [asp_databases] Re: FOR....LOOP
>
>
> Sorry my message wasn't clear enough. My goal is to display 5 questions
> on each page and have a NEXT button at the end of each page to allow the
> user to go to the next page until all the questions are addressed.
>
> > Hi,
> >
> > I am building a data driven Survey application. It's a long survey
(100
> > questions) and I would like to display 5 questions on each page. I was
> > sucessfully written a page that could display all the questions and
> values
> > on the web. I know a For....Loop would do it but since I am new to
> asp,
> > it's like a pain in neck.
> >
> > I would appreciate if you can give me a line of code or a site where I
> can
> > learn how to do this.
> >
> >
>
> $subst('Email.Unsub').
>
>
> $subst('Email.Unsub').
>
>
> $subst('Email.Unsub').
>
|
|
 |