View Single Post
  #4 (permalink)  
Old 02-07-2006, 06:23 PM
webmaster@pinecone.com webmaster@pinecone.com is offline
WebProWorld New Member
 

Join Date: Sep 2005
Posts: 15
webmaster@pinecone.com RepRank 0
Default Passing values into a sql statement from a form

I see a couple of problems in your code. First, you have two forms created....you should only submit a single form. You are also not referencing the form fields correctly.

Here's a skeleton example. You can fill in the blanks since it is not complete nor optimized, but it should give you a general idea of how to proceed...


bulletin_dropdown_menu.asp

<form name="bulletin_form" method="post" action="test_post.asp">


<%
open DB
do you query
If not r.eof Then
%>
<select name="month_selected">
<%
Do while not r.eof
%>
<option value="<%=r(month)%>"><%=r("month")%></option>
r.movenext
Loop
%>
</select>
<%
End If
%>


<%
close your recordset
do your second query
If not r.eof Then
%>
<select name="year_selected">
<%
Do while not r.eof
%>
<option value="<%=r(year)%>"><%=r("year")%></option>
r.movenext
Loop
%>
</select>
<%
End If
%>

<input type="submit" value="submit">
</form>

<%
close the recordset
close the DB connection
%>

test_post.asp


<%
Dim strSql
strSQL = "select month, year, link_name, link_filename, post_desc "
strSQL = strSQL & "from bulletintable"
strSQL = strSQL & "where month='"& request("month_selected") &"' and year='"& request ("year_selected") &"'"




Reply With Quote