how to search a database help me


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: how to search a database help me

  1. #1
    achyuth Guest

    how to search a database help me


    hi

    i have a data base consits of many fields and i want to search that database
    through some fields

    there are 5fields in search any one field is neccery those are name,age,sex,city
    and college in these one field is neccery and others are optional age should
    have range like 15to18 it should search in that range plz help plz help if
    u know

    u can see yahoo members directory-advence search for further deatils
    oif how it should look

  2. #2
    Kris Eiben Guest

    Re: how to search a database help me

    <%
    name = request.form("name")
    age1 = request.form("age1")
    age2 = request.form("age2")
    sex = request.form("sex")
    city = request.form("city")
    college = request.form("college")

    if name = "" and age1 = "" and age2 = "" and sex = "" and city = "" and
    college = "" then response.redirect "you_didnt_enter_any_data.asp"

    SQL = "Select {fieldlist} from {table} where 1=1 "

    if name <> "" then
    SQL = SQL & " and upper(name) like '%" & ucase(name) & "%' "
    end if
    if age1 <> "" then
    SQL = SQL & " and age > " & age1
    end if
    if age2 <> "" then
    SQL = SQL & " and age < " & age2
    end if
    if sex <> "" then
    SQL = SQL & " and sex = '" & sex & "'"
    end if
    if city <> "" then
    SQL = SQL & " and upper(city) = '" & ucase(city) & "'"
    end if
    if college <> "" then
    SQL = SQL & " and upper(college) like '%" & ucase(college) & "%'"
    end if
    %>
    Or something like that.

    achyuth wrote in message <3a26be84$1@news.devx.com>...
    >
    >hi
    >
    > i have a data base consits of many fields and i want to search that

    database
    >through some fields
    >
    > there are 5fields in search any one field is neccery those are

    name,age,sex,city
    >and college in these one field is neccery and others are optional age

    should
    >have range like 15to18 it should search in that range plz help plz help if
    >u know
    >
    > u can see yahoo members directory-advence search for further deatils
    >oif how it should look




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center