SQL Statements and Listboxes

Results 1 to 2 of 2

Thread: SQL Statements and Listboxes

  1. #1
    Join Date
    Dec 1969

    Default SQL Statements and Listboxes

    How does one write a Sql statement WHERE "something" equals the value of an option selected (by the user) from a list box/dopdown menu?

  2. #2
    Join Date
    Dec 1969

    Default RE: SQL Statements and Listboxes

    Lets say you have two asp pages: select.asp & query.asp.<BR><BR>Select.asp: contains the drop-down list. <BR>If, this is a list of categories, or the like, then store them all in a table, query that table in select.asp, and create the drop-down using the info from this query.<BR><BR>query.asp: Will run your main query (The reason for the 2 pages)<BR>This page will receive the input from the form in select.asp. This page will assemble the query, run it, and then display the result.<BR><BR>Notes:<BR>1) [select.asp will put together a drop-down, kinda like this:]<BR>&#060;select name="category"&#062;<BR>&#060;option value=catID1&#062;Category 1<BR>&#060;option value=catID2&#062;Category 2<BR>&#060;/select&#062;<BR><BR>2) [query.asp would grab that info using:]<BR>strCategoryID = Request.Form("category")<BR><BR>strSQL = "Select * from somTable where categoryID = " & strCategoryID<BR><BR><BR>Notice that you can use &#060;option&#062; tag&#039;s "value" property. If you have ID&#039;s place them in the value property, (i.e. hide them from your users, they don&#039;t want to see numbers, they wanna see words they can read & comprehend) and use names or something meanigful to the user for display in the list. <BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts