Forum Moderators: open

Message Too Old, No Replies

search

         

jbhavin

8:53 am on Sep 6, 2003 (gmt 0)

10+ Year Member



how do i do searchin within my database and dipaly it on a webpage in asp!

bateman_ap

5:03 pm on Sep 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi jbhavin,

This will create a simple search page, first build a form with a search field and pass this to a search results page.

Then you can use the following code

srchname = Replace(Request.Form("search"), "'", "''")

sSQL = "SELECT * FROM table WHERE field like "'%" &srchname& "%' order by field"

Then you can display all the results using

<%
IF rs.EOF AND rs.BOF THEN
Response.Write "Sorry, your search returned no results."
ELSE
rs.MoveFirst
Do While Not rs.EOF
Response.Write "Add your code here"

rs.MoveNext
Loop
end if
%>