ldg1976 Posted December 20, 2007 Share Posted December 20, 2007 Hi - I'm new to ASP&SQL and would like someone to point me in the right direction with my code below. My form below takes info from 2 categories within a table (fields location and category) which are displayed in the form and when selected are displayed on the next page (result.asp). My problem is that I need the rest of the info from the table (i.e name, address, email) that relates to the specific location and category.If anyone can help in any way shape or form in how/where I add the SQL query to get the info onto the results.asp, it will be a great help!search.asp <%@ Language=VBScript %><% Option Explicit %><!--#include file="dbconnection.asp"--><%Dim rsName%><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body> <form action="result.asp" method="post" name="frmsearch" id="frmsearch"> <table width="469" border="0"> <!--DWLayoutTable--> <tr> <td width="63" height="24" valign="top"><strong>Location:</strong></td> <td colspan="2" rowspan="2" valign="top"> <p> <b> <% set rsName = Server.CreateObject("ADODB.Recordset") rsName.ActiveConnection = strConnection rsName.Source = "SELECT DISTINCT location FROM info order by location asc" rsName.CursorType = 0 rsName.CursorLocation = 2 rsName.LockType = 3 rsName.Open() %> </b> <select name="location"> <% Do While Not rsName.EOF %> <option value="<%=rsName.fields.item("location").value%>"><%=rsName.fields.item("location").value%></option> <% rsName.MoveNext Loop %> </select> <b>and </b></td> </tr> <tr> <td height="13"></td> </tr> <tr> <td height="22"></td> <td width="1"> </td> <td width="391"></td> </tr> <tr> <td height="22" colspan="2" valign="top"><strong>Category:</strong></td> <td rowspan="2" valign="top"> <% set rsName = Server.CreateObject("ADODB.Recordset") rsName.ActiveConnection = strConnection rsName.Source = "SELECT DISTINCT category FROM info order by category asc" rsName.CursorType = 0 rsName.CursorLocation = 2 rsName.LockType = 3 rsName.Open() %> <select name="category"> <% Do While Not rsName.EOF %> <option value="<%=rsName.fields.item("category").value%>"><%=rsName.fields.item("category").value%></option> <% rsName.MoveNext Loop %> </select> <p> <input type="submit" name="Submit" value="Search" /> </td> </tr> <tr> <td height="45"> </td> <td> </td> </tr> </table> </form></body></html> result.asp <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%><% Option Explicit %><%Dim rsName%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><%=request.form("category")%> in <%=request.form("location")%> <br><br>Name Address Email (info that matches the selected category and location)</body></html> Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.