-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks