<!--#include virtual="/Connections/string.asp" -->
<form name="search" method="post" action="highlight_search.asp">
<table width="100%" border="1">
<tr><td><div align="center">Search our FAQ's</div></td></tr>
<tr><td>Enter Search Term</td></tr>
<tr><td><input type="text" name="searchterm">
<input type="submit" name="Submit" value="Search">
</td></tr></table></form>
<style>
.keyword {
background: yellow;
font-style: bold;
}
</style>
MY RESULTS PAGE
<%
DIM strSearchterm
strSearchterm = Request.Form("searchterm")
IF strSearchterm <> "" THEN%>
<%
DIM mySQL, objRS, rsDsearch_cmd, objRS_numRows
mySQL = "SELECT * FROM dbo.FAQs WHERE (QUESTIONS LIKE '%" & strSearchterm & "%') OR (ANSWERS LIKE '%" & strSearchterm & "%')"
Set objRS = con.Execute(mySQL)
objRS_numRows = 0
IF objRS.EOF THEN
Response.Write "Sorry, no records were found for that searchterm"
ELSE
%>
<table width="100%">
<tr><td>Question</td><td>Answer</td></tr>
<% DO WHILE NOT objRS.EOF %>
<tr><td><%=Replace(objRS("ANSWER"),strSearchterm,"<span class=""keyword"">"&strSearchterm&"</span>",1,1,1)%></td>
<%
objRS.MoveNext
Loop
END IF
%>
</table>
<%
ELSE
' No searchterm submitted, display blank
END IF
%>
|