|
| |
|
|
nettop
Posts: 210 Joined: 2/9/2004 Status: offline
|
Search multiple fields from one entry - 11/27/2005 15:34:59
I have a database at http://www.saccountyemd.net/test2/faqs.asp that searches ONLY the 'keyword' field. Is there a way to search also the 'Question' and 'Answer' field at the same time as the 'keywords' field? Thanks, Tim Here is my existing HTML: <h2>Frequently Asked Questions (FAQs)</h2>
<form BOTID="0" METHOD="POST" action="faqs.asp">
<input type="hidden" name="fpdbr_0_PagingMove" value=" |< ">
<table BORDER="0">
<tr>
<td><b><font face="Arial" size="2">Search by Keywords (enter all or part of a keyword):</font></b></td>
<td>
<input NAME="Misc2" VALUE="<%=Server.HtmlEncode(Request("Misc2"))%>" size="40"></td>
</tr>
</table>
<br>
<input TYPE="Submit"><input TYPE="Reset"><!--webbot bot="SaveAsASP" clientside suggestedext="asp" preview=" " startspan --><!--webbot bot="SaveAsASP" endspan --></form>
<table width="100%" border="0">
<thead>
</thead>
<tbody>
<!--#include file="../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM Results WHERE (Misc2 LIKE '%::Misc2::%') ORDER BY Division ASC,Program ASC"
fp_sDefault="Misc2="
fp_sNoRecords="<tr><td colspan=6 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="faqs"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=15
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&Key=3&Division=202&Program=202&Question=203&Answer=203&Link=202&Name=202&Misc1=202&Misc2=203&"
fp_iDisplayCols=6
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<tr>
<td><b><font size="2">Division: </font></b>
<font size="2">
<%=FP_FieldVal(fp_rs,"Division")%>
<b>Program: </b>
<%=FP_FieldVal(fp_rs,"Program")%></font></td>
</tr>
<tr>
<td><b><font size="2">Question: </font></b>
<font size="2">
<%=FP_FieldVal(fp_rs,"Question")%></font></td>
</tr>
<tr>
<td><b><font size="2">Answer: </font></b>
<font size="2">
<%=FP_FieldVal(fp_rs,"Answer")%></font></td>
</tr>
<tr>
<td><b><font size="2">Keywords: </font></b>
<font size="2">
<%=Highlight(FP_FieldVal(fp_rs,"Misc2"))%></font></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><font size="2">
<%="<a href=""" & FP_FieldLink(fp_rs,"Link") & """>" & FP_Field(fp_rs,"Link") & "</a>"%></font></td>
</tr>
<tr>
<td colspan="6"><hr noshade color="#000080" width="90%">
</td>
</tr>
<!--#include file="../_fpclass/fpdbrgn2.inc"-->
</tbody>
</table>
<p> </td>
</tr>
< Message edited by BeTheBall -- 2/3/2007 15:03:43 >
|
|
|
|
BeTheBall
Posts: 6336 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: Search multiple fields from one entry - 11/28/2005 8:49:48
Assuming you want to search multiple fields for the same keyword(s), something like: SELECT * FROM Results WHERE (Misc2 LIKE '%::Misc2::%' OR field2 LIKE '%::Misc2::%' OR Field3 LIKE '%::Misc2::%') ORDER BY Division ASC,Program ASC
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
nettop
Posts: 210 Joined: 2/9/2004 Status: offline
|
RE: Search multiple fields from one entry - 12/23/2005 11:09:03
I'm still trying to get this multi search/select function to work. My goal is to be able to input a word into the search field and have it search the fields 'Keywords', 'Description' and 'Location' from this one entry. I would also like any matches found to be highlighted in yellow, like have have working currently for the 'Keywords' field below. The page with this funtionality working for the 'Keywords' field is at http://www.ncleha.org/larrygordon/default.asp with the following code...thanks for your help, Tim: <%
Function Highlight(myString)
myKeywords = Request.Form("Keywords")
arrmyKeywords = Split(myKeywords, " ")
myOutput = myString
For i = 0 to Ubound(arrmyKeywords)
myOutput = Replace(myOutput, arrmyKeywords(i), "<span style='background-color:yellow'>"&arrmyKeywords(i)&"</span>",1,1,1)
Next
Response.write myOutput
End Function
%>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Larry Gordon Papers</title>
<meta name="Microsoft Border" content="none, default">
</head>
<body>
<!--webbot bot="Include" U-Include="../menu_top.htm" TAG="BODY" --><table
border="0" cellpadding="0" style="border-collapse: collapse" width="100%"
id="table9">
<tr>
<td><!--webbot bot="Include" U-Include="../top_footer.htm" TAG="BODY" --></td>
</tr>
</table>
<p>
<font face="Arial"><b>Welcome to the Larry Gordon Papers (<a href="bio.htm">view
Larry's Bio</a>)</b></font></p>
<form BOTID="0" METHOD="POST" action="default.asp">
<input type="hidden" name="fpdbr_0_PagingMove" value=" |< ">
<table BORDER="0">
<tr>
<td><b><font face="Arial" size="2">Search by Keywords (enter all or part of a keyword):</font> </b>
</td>
<td>
<input NAME="Keywords"
VALUE="<%=Server.HtmlEncode(Request("Keywords"))%>" size="40"></td>
</tr>
</table>
<br>
<input TYPE="Submit"><input TYPE="Reset"><!--webbot bot="SaveAsASP"
clientside suggestedext="asp" preview=" " startspan --><!--webbot bot="SaveAsASP" endspan --></form>
<table width="100%" border="1" bordercolor="#000080" cellpadding="2"
cellspacing="0">
<thead>
<tr>
<th ALIGN="LEFT" bgcolor="#FFFF00"><font face="Arial" size="2"><b>Title</b></font></th>
<th ALIGN="LEFT" bgcolor="#FFFF00"><font face="Arial" size="2"><b>Date
Published</b></font></th>
<th ALIGN="LEFT" bgcolor="#FFFF00"><font face="Arial" size="2"><b>Location</b></font></th>
<th ALIGN="LEFT" bgcolor="#FFFF00"><font face="Arial" size="2"><b>
Description</b></font></th>
<th ALIGN="LEFT" bgcolor="#FFFF00"><font face="Arial" size="2"><b>Keywords</b></font></th>
</tr>
</thead>
<tbody>
<!--#include file="../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM Results WHERE (Keywords LIKE '%::Keywords::%') ORDER BY Title ASC"
fp_sDefault="Keywords="
fp_sNoRecords="<tr><td colspan=5 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="larrygordon"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=20
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&ID=3&Title=202&Filename=202&Date_Published=202&Location=202&Description=203&Keywords=203&Remote_computer_name=202&User_name=202&Browser_type=202&Timestamp=135&Keywords1=203&"
fp_iDisplayCols=5
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<tr>
<td><font face="Arial" size="2">
<a href="<%=FP_FieldLink(fp_rs,"Filename")%>"><%=FP_FieldVal(fp_rs,"Title")%></a></font></td>
<td><font face="Arial" size="2"><%=FP_FieldVal(fp_rs,"Date_Published")%></font></td>
<td><font face="Arial" size="2"><%=FP_FieldVal(fp_rs,"Location")%></font></td>
<td><font face="Arial" size="2"><%=FP_FieldVal(fp_rs,"Description")%></font></td>
<td><font face="Arial" size="2"><%=Highlight(FP_FieldVal(fp_rs,"Keywords"))%></font></td>
</tr>
<!--#include file="../_fpclass/fpdbrgn2.inc"-->
</tbody>
</table>
<p>
</p>
<p></p>
<p></p>
<p></p>
<hr noshade color="#000080" width="80%" size="3">
<!--webbot bot="Include"
U-Include="../footer.htm" TAG="BODY" --> </body>
</html>
< Message edited by BeTheBall -- 2/3/2007 15:04:14 >
|
|
|
|
BeTheBall
Posts: 6336 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: Search multiple fields from one entry - 12/23/2005 11:26:21
So does changing your SQL to the following not work? SELECT * FROM Results WHERE (Keywords LIKE '%::Keywords::%' OR Description LIKE '%::Keywords::%' OR Location LIKE '%::Keywords::%') ORDER BY Title ASC Then add your highlight function before the output like you did in this line: <td><font face="Arial" size="2"><%=Highlight(FP_FieldVal(fp_rs,"Keywords"))%></font></td> Having said that, do you realize your search only works if the user enters a single word or an exact phrase? In other words if the user enters two words the only results that will be returned will be those where the two words appear right next to each other in the same order the user entered them. You may want to give this a read: http://www.frontpagewebmaster.com/m-305308/tm.htm#305317
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
nettop
Posts: 210 Joined: 2/9/2004 Status: offline
|
RE: Search multiple fields from one entry - 12/23/2005 15:27:40
Thanks, this works well. I will read the article you refer to so that I might further improve the search functions. I appreciate, as always, your wisdom and assistance. Have a GREAT day, Tim
|
|
|
|
nettop
Posts: 210 Joined: 2/9/2004 Status: offline
|
RE: Search multiple fields from one entry - 2/3/2007 14:55:43
I'm trying to do the same multiple search on a new page and the using one field to search 3 fields is working fine (though I will be expanding it to search more fields in a bit). Currently, I'm having problems getting my form to 'yellow highlight' the words it finds on the search results page. Here is my current code. You can see the form at: http://www.paramountbusinessbrokers.com/admin/12_buyers_purchase_searchA1-3test.asp Try entering the word 'exec' and you'll see it return 2 records. I would like the letters 'exec' highlighted in yellow so the viewer can see their results. Please help, Thanks, Tim <%
Function Highlight(myString)
myFirst_Name = Request.Form("A1_Experience")
arrmyA1_Experience = Split(myA1_Experience, " ")
myOutput = myString
For i = 0 to Ubound(arrmyA1_Experience)
myOutput = Replace(myOutput, arrmyA1_Experience(i), "<span style='background-color:yellow'>"&arrmyA1_Experience(i)&"</span>",1,1,1)
Next
Response.write myOutput
End Function
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Buyers Purchase Questionairre</title>
<meta name="Microsoft Border" content="b">
</head>
<body>
<div align="center">
<p align="right"><a target="_top" href="default.asp">Return to Bret's Page</a></p>
<table border="0" width="100%">
<tr>
<td>
<div align="center">
<table border="0" width="801" cellspacing="0" bordercolor="#000000">
<tr>
<td align="center">
<!-- #include file="../_includes/menu_top1.inc" -->
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
<p><b><span style="font-size: 11.0pt; font-family: Arial,sans-serif">Buyer
Information & Questionnaire</span></b></p>
<form BOTID="0" METHOD="POST" action="12_buyers_purchase_searchA1-3test.asp">
<input type="hidden" name="fpdbr_0_PagingMove" value=" |< ">
<table BORDER="0">
<tr>
<td><b>A1_Experience</b></td>
<td>
<input NAME="A1_Experience" VALUE="<%=Server.HtmlEncode(Request("A1_Experience"))%>" size="40"></td>
</table>
<br>
<input TYPE="Submit"><input TYPE="Reset"><input type="hidden" name="fpdbr_0_PagingMove" value=" |< "></form>
</form>
<table width="100%" border="1">
<thead>
<tr>
<th ALIGN="LEFT"><b>ID</b></th>
<th ALIGN="LEFT"><b>First_Name</b></th>
<th ALIGN="LEFT"><b>Last_Name</b></th>
<th ALIGN="LEFT"><b>Cell_Phone</b></th>
<th ALIGN="LEFT"><b>Day_Phone</b></th>
<th ALIGN="LEFT"><b>Email</b></th>
<th ALIGN="LEFT"><b>A1_Experience</b></th>
<th ALIGN="LEFT"><b>A2_Education</b></th>
<th ALIGN="LEFT"><b>A3_Occupation</b></th>
</tr>
</thead>
<tbody>
<!--#include file="../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM Results WHERE (A1_Experience LIKE '%::A1_Experience::%' OR A2_Education LIKE '%::A1_Experience::%' OR A3_Occupation LIKE '%::A1_Experience::%') ORDER BY Timestamp DESC"
fp_sDefault="A1_Experience="
fp_sNoRecords="<tr><td colspan=9 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="12_buyers_info"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&ID=3&First_Name=202&Last_Name=202&Address=202&City=202&State=202&Zip=202&Spouse_Name=202&Cell_Phone=202&Day_Phone=202&Email=202&A1_Experience=203&A2_Education=203&A3_Occupation=203&B1_Manufacturing_Related=202&B1_Service_Related=202&B1_Restaurants_FoodService=202&B1_Markets_GroceryStores=202&B1_Wholesale_Distribution=202&B1_Retail_Related=202&B1_Hotels_Motels_BBs=202&B1_Auto_Related_GasCarWashesAutoRepair=202&B1_Other=202&B1_Other_Details=202&B2_Purchase_Type=203&B3_Purchase_Not=203&B4_1Sacramento=202&B4_2_Roseville_Rocklin_Loomis=202&B4_3_Davis_Woodland=202&B4_4_RanchoCordova=202&B4_5_Folsom_ElDoradoHills=202&B4_6_Placerville=202&B4_7_Auburn=202&B4_8_GrassValley_NevadaCity=202&B4_9_Oroville=202&B4_10_ChicoArea=202&B4_11_Other=202&B5_Miles=202&B6_1_Working_Owner_Operator=202&B6_2_Absentee_Owner=202&B6_3_Strategic_Advisor=202&B7_Annual_Income=202&B8_Adjusted_Net_Income=202&B9_Timeframe=202&B10_Yes=202&B10_No=202&B10_Explain=203&B11_Why_Motivated_To_Buy_Now=203&C1_Yes=202&C1_No=202&C1_Other_Buyers_Roles=203&C2_Credit_Excellent=202&C2_Credit_VeryGood=202&C2_Credit_Good=202&C2_Credit_Poor=202&C3_Bankruptcy_Yes=202&C3_Bankruptcy_No=202&C4_Tax_Liens_or_Judgements_Yes=202&C4_Tax_Liens_or_Judgements_No=202&C4_Tax_Liens_or_Judgements_Filed=203&C5_How_Much_Cash_Down_Now=202&D1_Cash=202&D2_Stocks_Bonds_NonPension=202&D3_Stocks_Bonds_Pension=202&D4_Real_Estate_Personal=202&D5_Real_Estate_Other=202&D6_Value_Business_Owned=202&D7_Total_Assets=202&E1_Loans_Personal_Residence=202&E2_Loans_Other_Real_Estate=202&E3_Credit_Card_Liability=202&E4_Other_Revolving_Debt=202&E5_Total_Liabilities=202&E6_Net_Worth=202&F1_Employment_Salary=202&F2_Spouses_Employment_Salary=202&F3_Real_Estate_Income=202&F4_Other_Income=202&F5_Total_Annual_Income=202&G1_Date_Signed=202&G2_Signature=202&Remote_computer_name=202&User_name=202&Browser_type=202&Timestamp=135&"
fp_iDisplayCols=9
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<tr>
<td>
<%=FP_FieldVal(fp_rs,"ID")%></td>
<td>
<%=FP_FieldVal(fp_rs,"First_Name")%></td>
<td>
<%=FP_FieldVal(fp_rs,"Last_Name")%></td>
<td>
<%=FP_FieldVal(fp_rs,"Cell_Phone")%></td>
<td>
<%=FP_FieldVal(fp_rs,"Day_Phone")%></td>
<td>
<%=FP_FieldVal(fp_rs,"Email")%></td>
<td>
<%=Highlight(FP_FieldVal(fp_rs,"A1_Experience"))%></td>
<td>
<%=Highlight(FP_FieldVal(fp_rs,"A2_Education"))%></td>
<td>
<%=Highlight(FP_FieldVal(fp_rs,"A3_Occupation"))%></td>
</tr>
<!--#include file="../_fpclass/fpdbrgn2.inc"-->
</tbody>
</table>
</body>
</html>
< Message edited by BeTheBall -- 2/3/2007 15:04:45 >
|
|
|
|
BeTheBall
Posts: 6336 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: Search multiple fields from one entry - 2/3/2007 15:08:56
Looks like you may have missed an edit: <% Function Highlight(myString) myFirst_Name = Request.Form("A1_Experience") arrmyA1_Experience = Split(myA1_Experience, " ") myOutput = myString For i = 0 to Ubound(arrmyA1_Experience) myOutput = Replace(myOutput, arrmyA1_Experience(i), "<span style='background-color:yellow'>"&arrmyA1_Experience(i)&"</span>",1,1,1) Next Response.write myOutput End Function %> I think the line in bold should be: myA1_Experience = Request.Form("A1_Experience")
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
nettop
Posts: 210 Joined: 2/9/2004 Status: offline
|
RE: Search multiple fields from one entry - 2/3/2007 15:37:10
Thanks Duane...such a simple thing...I proofed it a dozen times and must have had a block on this...the darn computer just doesn't read my mind very well does it??? Take care, Tim
|
|
|
|
Geraldo
Posts: 57 From: Eindhoven Status: offline
|
RE: Search multiple fields from one entry - 3/24/2008 12:07:53
Hi All, using this code I have managed to highlight each first occurance of a searched word in every single result. Would it also be possible to highlight more occurances of a search world in case that this word is several times in a single result. Regards Geraldo
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|