Forums

PHP

This topic is locked

update records in database

Posted 02 Sep 2006 13:16:04
1
has voted
02 Sep 2006 13:16:04 Sakina Allawati posted:
hello. I'm learning dreamweaver (asp codes). I have created a questionnaire linked to the database.
I have checkboxes and radio buttons and I want by checking the answer the no. of counts increse in the database

I have created these two pages and I don't know how to link them. I know there is a proplem in some parts but I can't fiqure them so can anyone help me in that

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/survey_conn.asp" -->
<% If Request.Form("checkbox" = "0" Then %>


<%
set cmdUpdateAns = Server.CreateObject("ADODB.Command"
cmdUpdateAns.ActiveConnection = MM_survey_conn_STRING
cmdUpdateAns.CommandText = "UPDATE answers SET counts = counts + 1 WHERE answer_no = " & Request.QueryString("answer_no"
cmdUpdateAns.CommandType = 1
cmdUpdateAns.CommandTimeout = 0
cmdUpdateAns.Prepared = true
cmdUpdateAns.Execute()
%>
<%
set cmdUpdateQues = Server.CreateObject("ADODB.Command"
cmdUpdateQues.ActiveConnection = MM_survey_conn_STRING
cmdUpdateQues.CommandText = "UPDATE questions SET Total_votes = Total_votes + 1 WHERE Question_No =1 "
cmdUpdateQues.CommandType = 1
cmdUpdateQues.CommandTimeout = 0
cmdUpdateQues.Prepared = true
cmdUpdateQues.Execute()



Response.Redirect("localhost:88/survey_page/question22.asp")
%>


<% End If %>



<%@LANGUAGE="VBSCRIPT"%>

<%
Dim rsQuest__numRows
Dim rsQuest__index

rsQuest__numRows = -1
rsQuest__index = 0
rsQuest_numRows = rsQuest_numRows + rsQuest__numRows
%>
<!--#include file="Connections/survey_conn.asp" -->
<%
Dim rsQues2
Dim rsQues2_numRows

Set rsQues2 = Server.CreateObject("ADODB.Recordset"
rsQues2.ActiveConnection = MM_survey_conn_STRING
rsQues2.Source = "SELECT * FROM questions WHERE question_no=2"
rsQues2.CursorType = 0
rsQues2.CursorLocation = 2
rsQues2.LockType = 1
rsQues2.Open()

rsQues2_numRows = 0
%>
<%
Dim rsAnswer2
Dim rsAnswer2_numRows

Set rsAnswer2 = Server.CreateObject("ADODB.Recordset"
rsAnswer2.ActiveConnection = MM_survey_conn_STRING
rsAnswer2.Source = "SELECT answers.answer_no, answers.Question_No, answers.answers, answers.counts FROM answers, questions WHERE questions.Question_No= answers.Question_No and questions.question_no=2"
rsAnswer2.CursorType = 0
rsAnswer2.CursorLocation = 2
rsAnswer2.LockType = 1
rsAnswer2.Open()

rsAnswer2_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsAnswer2_numRows = rsAnswer2_numRows + Repeat1__numRows
%>

<html>
<head>
<title>Question1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#666666">
<tr>

</tr>
</table>
<table width="100%" border="0">
<tr>
<td><p><strong><%=(rsQues2.Fields.Item("About".Value)%>:</strong></p>
<p><%=(rsQues2.Fields.Item("Question".Value)%></p></td>
</tr>
<tr>
<td height="144">
<form method="get" action="localhost:88/survey_page/vote2.asp" name="form1">
<table width="477" >
<tr valign="baseline">
<td width="81" align="right" nowrap> </td>
<td colspan="2"> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Question No:</td>
<td width="230"><%=(rsAnswer2.Fields.Item("Question_No".Value)%></td>
<td width="150">Counts:</td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsAnswer2.EOF))
%>
<tr valign="baseline">
<td nowrap align="right"><input type="hidden" name="answer_no" value="<%= rsAnswer2.Fields.Item("answer_no".Value %>"></td>
<td valign="top">
<input type="checkbox" name="answers" value=<%=(rsAnswer2.Fields.Item("answer_no".Value)%> >
<option value="<%=(rsAnswer2.Fields.Item("answer_no".Value)%>"><%=(rsAnswer2.Fields.Item("answers".Value)%></option>       </td>
<td valign="top"><input type="text" name="counts" value="<%=(rsAnswer2.Fields.Item("counts".Value)%>" size="10"></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsAnswer2.MoveNext()
Wend
%>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td colspan="2"> <input name="submit" type="submit" value="Update Record">
</td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
</form>
</td>
</tr>

<TR align="left">
<TD colspan="2" valign="middle" class="text"></TD>
</TR>
</table>

</body>
</html>
<%
rsQues2.Close()
Set rsQues2 = Nothing
%>

<%
rsAnswer2.Close()
Set rsAnswer2 = Nothing
%>

Thank you

Replies

Replied 03 Oct 2006 19:56:21
03 Oct 2006 19:56:21 Tracy Sweder replied:
You may want to post this in the "ASP" forum rather than the "PHP" forum <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>

Reply to this topic