Easy seach question

Results 1 to 4 of 4

Thread: Easy seach question

  1. #1
    Yepnab Guest

    Default Easy seach question

    I am writting a seach page that seaches certain fields in my database. The problem is that when a user opens the page it automatically queries that database bringing all of the information from the sql that i wrote. How do i prevent this?? So that the page only opens up with links and the input form.

  2. #2
    Join Date
    Dec 1969
    Posts
    1,019

    Default RE: Easy seach question

    I&#039m not sure what you mean. Do you want the page only to show search results according to the what a user entered on an input screen?:<BR>pg1.asp has input options, which are submitted to pg2.asp<BR>pg2.asp shows the results matching the users selections<BR>? - If this isn&#039t what you meant, code samples would be helpful.<BR>

  3. #3
    yeps Guest

    Default RE: Easy seach question

    Correct, I only want what the user inputs

  4. #4
    Join Date
    Dec 1969
    Posts
    1,019

    Default RE: Easy seach question

    Ok - just test to see if the user entered anything into the form fields. If not, don&#039t add it to the sql statement:<BR>dim sql<BR>sql="SELECT * FROM myTable WHERE "<BR>&#039 Start the sql statement<BR>if request("field1")&#060;&#062;"" then<BR>sql=sql & "(col1=" & request("field1") & ") AND"<BR>end if<BR>&#039 If the user entered info in the field, add it to the query<BR>if request("field2")&#060;&#062;"" then<BR>sql=sql & "(col2=" & request("field2") & ") AND"<BR>end if<BR>&#039 do this as many times as you want & execute<BR>&#039 Make sure you have no dangling ANDs<BR>dbconn.execute(sql)


Posting Permissions

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