Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

beginner trying to show response

Status
Not open for further replies.

nic02

Technical User
Oct 1, 2001
1
GB
I'm trying to compile a question and answers page
I'm able to show my questions but on click
of a question I want to show the selected ques and its corr Answer.
The code I have:

Code:
sqltemp = "select * from QA where TYPE = 'G' order by id"
set rstemp=conntemp.execute(SQLTemp)

sqltemp = "select * from QA where TYPE = 'E' order by id"
set rstemp1=conntemp.execute(SQLTemp)

sqltemp = "select * from QA where TYPE = 'C' order by id"
set rstemp2=conntemp.execute(SQLTemp)

sqltemp = "select * from QA where TYPE = 'P' order by id"
set rstemp3=conntemp.execute(SQLTemp)

sqltemp = "select * from QA where TYPE = 'Q' order by id"
set rstemp4=conntemp.execute(SQLTemp)%>


Code:
<%do while not rstemp.EOF%>
<font size=&quot;3&quot; color=&quot;#5894ae&quot;>
<a href=&quot;AnswerSearch.asp&quot; style=&quot;TEXT-DECORATION: none&quot; target = &quot;Main&quot; class=fp>
<STRONG>
Code:
<%response.write rstemp(&quot;QUESTIONS&quot;)%>
</STRONG></font>
<P>
<%
rstemp.MoveNext
loop%>

and so on for each heading.....

I'm able to show my response, what I'm after doing is ---

Once my repsonse is visible I then want to click an the supplied question to show the question and answer.
Is this possible? If so could someone please SHOW ME THE CODE.
 
you should keep a column in the table called, for example, QuestionID, and declare it as int, primary key and identity.
this will make it increment by one everytime a new row is added.
now to your code:
<%do while not rstemp.EOF%>
<font size=&quot;3&quot; color=&quot;#5894ae&quot;>
<a href=&quot;AnswerSearch.asp?qid=<%=rstemp(&quot;QuestionID&quot;)%>&quot; style=&quot;TEXT-DECORATION: none&quot; target = &quot;Main&quot; class=fp>
<STRONG><%=rstemp(&quot;QUESTIONS&quot;)%></STRONG></font>
<P>
<%
rstemp.MoveNext
loop%>
by adding the the ?qid=<%=rstemp(&quot;QuestionID&quot;)%> after the link you're able to read the question's id and refer to the appropriate answer.
you should add another table to hold the relationship between questions and answers or add another column to the answers table that includes the questions id that belongs to the answer.

to get the qeustion id the user clicked on just do this:
Dim intQuestionID
intQuestionID = Request.QueryString(&quot;qid&quot;)
now intQuestionID holds the requested question and you can go fetch the appropriate answer like this:

sqlanswer = &quot;select * from Answers where QuestionID=&quot;& intQuestionID
set rsanswer=conntemp.execute(sqlanswer)


:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top