Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search engine

Status
Not open for further replies.

WhiteTiger

Programmer
Jun 26, 2001
605
US
Hello again!...lol

I need some script to help get me started on making a searchable database through ASP...I dont know how to make one...it has to access a database, search and sort by either project number or project name. ----------------------------------------
The Learning process is just a way to get rid of all the stupids in your head.

Now where's that cute little kitten? :-X
 
U need one page for displaying what u want to search

somehtmlfile.htm

<form action=&quot;search.asp&quot; method=&quot;post&quot;>
Name:<input name=&quot;name&quot; id=&quot;name&quot;><br>
Number:<input name=&quot;nr&quot; id=&quot;nr&quot;><br>
<input type=&quot;submit&quot; value=&quot;Search Values&quot;>
</form>

and one page for displaying the search response
search.asp
<%
name=Request.Form(&quot;name&quot;)
if name=&quot;&quot; then
'put your error for name field
response.end
end if
nr=Request.Form(&quot;nr&quot;)
if not isnumeric(nr) then
'put your error for nr field
response.end
end if
nr=int(nr)
SQL=&quot;select Name, nr from MyDataBase where name like '%&quot;&name&&quot;%' and nr=&quot;&nr
'exec the SQL querry and then write the response...
%>

the &quot;%&quot; is for all characters in SQL statment

If u want more please let me know
________

George
 
Or this, dont know who i got it off....
<!-- #include file=&quot;connect.inc&quot;-->
<%
dim dsn,conn,rs,sql,x
dim flag,color,useraction,element
useraction=request.querystring(&quot;action&quot;)
select case useraction
case &quot;search&quot;
x = 0
sql = &quot;select * from webdata where event = '&quot; &Request.Form (&quot;lname&quot;) & &quot;'&quot;
set conn = server.createObject(&quot;adodb.connection&quot;)
set rs = server.createObject(&quot;adodb.recordset&quot;)
conn.open gsConnect

for each element in request.form

if request.form(element)<>&quot;&quot; then

select case element
case &quot;tel&quot;
sql=sql & &quot; and tel = '&quot; & Request.form(element) & &quot;'&quot;
case &quot;lname&quot;
sql=sql & &quot; and lname like '&quot; & Request.form(element) & &quot;%'&quot;
case &quot;fname&quot;
sql=sql & &quot; and fname like '&quot; & Request.form(element) & &quot;%'&quot;
case &quot;init&quot;
sql=sql & &quot; and init like '&quot; & Request.form(element) & &quot;%'&quot;
case &quot;mobile&quot;
sql=sql & &quot; and mobile like '&quot; & Request.form(element) & &quot;%'&quot;
case &quot;dept&quot;
sql=sql & &quot; and dept like '&quot; & Request.form(element) & &quot;%'&quot;

end select
end if
next
sql=sql & &quot; order by id&quot;
'response.write sql'***debug
rs.open sql,conn
if rs.eof and rs.bof then
response.write &quot;No Record Found&quot;
else
response.write &quot;<table width=550 border=0><th align=left>Last Name</th><th align=left>First Name</TH>&quot;
response.write &quot;<th align=left>Tel</TH><th align=left>Mobile</TH><th align=left>Initials</TH><th align=left>Dept</TH>&quot;
do while not rs.eof
if flag=0 then
flag=1
color=&quot;#A5C3C3&quot;
else
flag=0
color=&quot;#FFFFC0&quot;
end if

response.write &quot;<TR bgcolor=&quot;& color & &quot;><TD>&quot;
response.write RS(&quot;id&quot;) & &quot;</td><td>&quot; & RS(&quot;event&quot;) & &quot;</td><td>&quot;
response.write RS(&quot;position&quot;) & &quot;</td><td>&quot; & RS(&quot;id&quot;) & &quot;</td><td>&quot; & RS(&quot;position&quot;) & &quot;</td><td>&quot;
response.write RS(&quot;position&quot;) & &quot;</tr></td>&quot;
rs.movenext
x=x+1
loop

response.write &quot;<tr><td colspan=7>Total Records : &quot; & x & &quot;</table>&quot;
end if
end select
%>
<script>function rusure() {

if (confirm(&quot;Are you sure you want to delete?&quot;)) {
return true;
} else {

return false;
}
}
</script>

<head>

<style>
a:hover{color:red}
</style>
<title>Telephone Directory</title>
</head>

<body link=&quot;#000080&quot; vlink=&quot;#000080&quot; alink=&quot;#000080&quot;>

<div align=&quot;center&quot;>
<center>

<table border=&quot;0&quot; width=&quot;450&quot; cellspacing=&quot;0&quot; cellpadding=&quot;3&quot; style=&quot;border:1px groove #B52100; border-collapse:collapse&quot; bordercolor=&quot;#111111&quot;>
<tr><td colspan=&quot;2&quot; align=&quot;center&quot;>
<p align=&quot;center&quot;><img border=&quot;0&quot; src=&quot;IMAGES/main.png&quot;></tr>
<form action=&quot;search.asp?action=search&quot; method=&quot;post&quot;>
<tr><td colspan=&quot;2&quot; align=&quot;center&quot; bgcolor=&quot;#B52100&quot;><font face=&quot;Verdana&quot; color=&quot;#FFFFFF&quot; size=&quot;1&quot;> Clicking on
<b> search</b> without choosing any category will retrieve all records</font></tr>
<tr><td bgcolor=&quot;#C0C0C0&quot;>
<font face=&quot;Verdana&quot; size=&quot;2&quot; color=&quot;#B52100&quot;>
Search by Last name:(A-Z)</font></td><td bgcolor=&quot;#C0C0C0&quot;>
<font face=&quot;Verdana&quot; color=&quot;#B52100&quot;><input type=&quot;text&quot; name=&quot;lname&quot; size=&quot;25&quot; maxlength=&quot;25&quot;></font></tr>
<tr><td bgcolor=&quot;#C0C0C0&quot;>
<font face=&quot;Verdana&quot; size=&quot;2&quot; color=&quot;#B52100&quot;>
Search by First name:(A-Z)</font></td><td bgcolor=&quot;#C0C0C0&quot;>
<font face=&quot;Verdana&quot; color=&quot;#B52100&quot;><input type=&quot;text&quot; name=&quot;fname&quot; size=&quot;25&quot; maxlength=&quot;25&quot;></font></tr>
<tr><td bgcolor=&quot;#C0C0C0&quot;>
<font face=&quot;Verdana&quot; size=&quot;2&quot; color=&quot;#B52100&quot;>
Search by Phone No .:</font></td><td bgcolor=&quot;#C0C0C0&quot;>
<font face=&quot;Verdana&quot; color=&quot;#B52100&quot;><input type=&quot;text&quot; name=&quot;tel&quot; size=&quot;10&quot; maxlength=&quot;5&quot;></font></tr>
<tr><td bgcolor=&quot;#C0C0C0&quot;>
<font face=&quot;Verdana&quot; size=&quot;2&quot; color=&quot;#B52100&quot;>
Search by Initials</font></td><td bgcolor=&quot;#C0C0C0&quot;>
<font face=&quot;Verdana&quot; color=&quot;#B52100&quot;><input type=&quot;text&quot; name=&quot;init&quot; size=&quot;5&quot; maxlength=&quot;5&quot;></font></tr>
<tr><td bgcolor=&quot;#C0C0C0&quot;>
<font face=&quot;Verdana&quot; size=&quot;2&quot; color=&quot;#B52100&quot;>
Search by Department</font></td><td bgcolor=&quot;#C0C0C0&quot;>
<font face=&quot;Verdana&quot; color=&quot;#B52100&quot;><input type=&quot;text&quot; name=&quot;dept&quot; size=&quot;25&quot; maxlength=&quot;25&quot;></font></tr>

<tr><td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot;>
<table border=&quot;0&quot; width=&quot;100%&quot;>
<tr>
<td width=&quot;33%&quot;></td>
<td width=&quot;33%&quot; style=&quot;border: 2px outset #B52100; &quot; align=&quot;center&quot;>
<p align=&quot;center&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;><a href=&quot;search.asp&quot; style=&quot;text-decoration:none&quot;>
<font color=&quot;#B52100&quot;>Clear</font></a></font></td>
<td width=&quot;34%&quot;></td>
</tr>
</table>
<td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot;>
<font face=&quot;Verdana&quot; color=&quot;#B52100&quot;>
<input type=&quot;submit&quot; value=&quot;Search&quot; style=&quot;border:2px ridge #B52100; background-color: #C0C0C0; &quot;></font></tr>
</table>
</center>
</div>
<p align=&quot;center&quot;>
</a></p>
</body>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top