Hi Everyone,
I got two parts of my advance search to work, I am running out of Logic to
connect the third. My mind is in swing! Pleaseeeeeeeee Help me.
I have 3 Fiels to search, the First two works, thats:
1. Category to search from the (Drop down name: ASPDBCatSearch) is working
with the Input Text Box Field (name: keyword), based on Whatever selection on
the Drop down value selection:
The "Option Value" FirstName,Title ,Email etc... is connected to the Input
Text Box Field (name: keyword) with the asp code thus:
' HTML Drop down Name | FirstName is the value name
If Request.Form("A SPDBCatSearch") = "FirstName" Then
' HTML Input Text Box name is keyword
SQL = SQL & " WHERE FirstName LIKE '%" & Request.Form("k eyword") & "%'
"
End If
The rest values based on selection works with the Keyword typing.
In Breiaf How can I connect the "Salary Drop down Values" to the Category
Search drop down + and the Input txt box Search to match the Exact Search?
Can Some one Give me two sentences of example with my above Added code as to
how the salary values should be added to the Category and Input txt box
fields in the asp code?
------------------------------------------------------------------------------
The html Code:
<table border="0" width="525" bgcolor="#FFFFF F" cellspacing="3"
cellpadding="3"
style="border: 0px outset #EEEEEE; ">
<tr>
<td width="515" bgcolor="#FFFFF F"><form action="Searche ngineresults.as p"
method="post" align="center">
<div align="center"> <center>
<table border="1" width="486" cellpadding="3"
bgcolor="#F5F5F 5" bordercolorligh t="#EEEEEE" style="border-collapse:
collapse">
<tr>
<td align="left" width="169"><st rong><font face="Tahoma">< big><big>
<font size="1">1.</font></big></big><font size="1"Select a category to
search</font></font></strong><p align="center"> <select
name="ASPDBCatS earch" size="1">
<option selected value="All">All </option>
<option value="FirstNam e">First Name</option>
<option value="LastName ">Last Name </option>
<option value="Title">T itle </option>
<option value="Division ">Dept/Div </option>
<option value="Phone">P hone </option>
<option value="Email">E-Mail </option>
</select></td>
<td align="left" width="106" bgcolor="#FF870 F"><strong><fon t
face="Tahoma">< big><big>
<font size="1">2.</font></big></big><font size="1">
Salary</font></font></strong><p>
<select name="Salarycom " size="1">
<option selected value="Allsal"> All</option>
<option value="10000">1 0000</option>
<option value="20000">2 0000</option>
<option value="30000">3 0000</option>
<option value="40000">3 0000</option>
<option value="50000">5 0000</option>
<option value="60000">6 0000</option>
<option value="70000">7 0000</option>
<option value="80000">8 0000</option>
<option value="90000">9 0000</option>
<option value="100000 or Abv">100000 or Abv</option>
</select></td>
<td width="172" align="right">
<p align="center"> <strong><font face="Tahoma">< big><big>
<font size="1">3.</font></big></big><font size="1"Type search
criteria</font></font></strong><p>
<input type="text" size="30" name="keyword"> </td>
</tr>
<tr>
<td colspan="3" align="center" width="478">
<p><input type="reset" name="B2" value="Clear">
<input type="submit" name="B1" value="Search employees"></td>
</tr>
</table>
</center></div>
</form>
</td>
</tr>
</table>
</center></div>
</body>
</html>
------------------------------------------------------------------------------
---------------------
ASP Code Searchengineres ults.asp
<%@ LANGUAGE="VBSCR IPT" %>
<html>
<head>
<title>Search Engine Results!</title>
</head>
<body>
<%
Dim SQL
Set aspdbweb = Server.CreateOb ject("ADODB.Con nection")
aspdbweb = "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" & Server.MapPath
("employees.mdb ") & ";"
SQL = "SELECT * FROM Employees"
' An Example on Salary Drop down Values to connect to the rest two (Category
and Input txt Box) please here will be appreciated
If Request.Form("A SPDBCatSearch") = "FirstName" Then
SQL = SQL & " WHERE FirstName LIKE '%" & Request.Form("k eyword") & "%' "
End If
If Request.Form("A SPDBCatSearch") = "LastName" Then
SQL = SQL & " WHERE LastName LIKE '%" & Request.Form("k eyword") & "%'"
End If
If Request.Form("A SPDBCatSearch") = "Title" Then
SQL = SQL & " WHERE Title LIKE '%" & Request.Form("k eyword") & "%'"
End If
If Request.Form("A SPDBCatSearch") = "Division" Then
SQL = SQL & " WHERE Division LIKE '%" & Request.Form("k eyword") & "%'"
End If
If Request.Form("A SPDBCatSearch") = "Phone" Then
SQL = SQL & " WHERE Phone LIKE '%" & Request.Form("k eyword") & "%'"
End If
If Request.Form("A SPDBCatSearch") = "Email" Then
SQL = SQL & " WHERE EMail LIKE '%" & Request.Form("k eyword") & "%'"
End If
Set rsglobal = Server.CreateOb ject("ADODB.Rec ordset")
rsglobal.Open SQL, aspdbweb, 3
%>
<%
If rsglobal.BOF and rsglobal.EOF Then%>
<h2 align="center"> We did not find a match!</h2>
<%Else%>
<%If Not rsglobal.BOF Then%>
<h2>Here are the results of your search:</h2>
<table BORDER="0" width="100%" cellpadding="3" >
<tr>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">First name </font></span></th>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">Last Name </font></span></th>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">Salary </font></span></th>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">Title </font></span></th>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">Divisi on </font></span></th>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">Phone </font></span></th>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">E-Mail </font></span></th>
</tr>
<%
Do While Not rsglobal.EOF
%>
<tr>
<td><%=rsglobal ("FirstName")%> </td>
<td><%=rsglobal ("LastName") %></td>
<td><%=rsglobal ("1SalaryDB")%> </td>
<td><%=rsglobal ("Title")%></td>
<td><%=rsglobal ("Division") %></td>
<td><%=rsglobal ("Phone")%></td>
<td><a href="mailto:<% =rsglobal("Emai l")%>"><%=rsglo bal("Email")%
</tr>
<% rsglobal.MoveNe xt
Loop
%>
</table>
<%End If%>
<%End If%>
<%
rsglobal.Close
%>
</body>
</html>
--------------------------------------------------------
Awaiting your favorable reply.
Thank you.
I got two parts of my advance search to work, I am running out of Logic to
connect the third. My mind is in swing! Pleaseeeeeeeee Help me.
I have 3 Fiels to search, the First two works, thats:
1. Category to search from the (Drop down name: ASPDBCatSearch) is working
with the Input Text Box Field (name: keyword), based on Whatever selection on
the Drop down value selection:
The "Option Value" FirstName,Title ,Email etc... is connected to the Input
Text Box Field (name: keyword) with the asp code thus:
' HTML Drop down Name | FirstName is the value name
If Request.Form("A SPDBCatSearch") = "FirstName" Then
' HTML Input Text Box name is keyword
SQL = SQL & " WHERE FirstName LIKE '%" & Request.Form("k eyword") & "%'
"
End If
The rest values based on selection works with the Keyword typing.
>>>>My Question is: I have added another drop Down Call salary (name: Salarycom), I need to add that to the Search Logic, and I am lost, How can I do this please?
Search drop down + and the Input txt box Search to match the Exact Search?
Can Some one Give me two sentences of example with my above Added code as to
how the salary values should be added to the Category and Input txt box
fields in the asp code?
------------------------------------------------------------------------------
The html Code:
<table border="0" width="525" bgcolor="#FFFFF F" cellspacing="3"
cellpadding="3"
style="border: 0px outset #EEEEEE; ">
<tr>
<td width="515" bgcolor="#FFFFF F"><form action="Searche ngineresults.as p"
method="post" align="center">
<div align="center"> <center>
<table border="1" width="486" cellpadding="3"
bgcolor="#F5F5F 5" bordercolorligh t="#EEEEEE" style="border-collapse:
collapse">
<tr>
<td align="left" width="169"><st rong><font face="Tahoma">< big><big>
<font size="1">1.</font></big></big><font size="1"Select a category to
search</font></font></strong><p align="center"> <select
name="ASPDBCatS earch" size="1">
<option selected value="All">All </option>
<option value="FirstNam e">First Name</option>
<option value="LastName ">Last Name </option>
<option value="Title">T itle </option>
<option value="Division ">Dept/Div </option>
<option value="Phone">P hone </option>
<option value="Email">E-Mail </option>
</select></td>
<td align="left" width="106" bgcolor="#FF870 F"><strong><fon t
face="Tahoma">< big><big>
<font size="1">2.</font></big></big><font size="1">
Salary</font></font></strong><p>
<select name="Salarycom " size="1">
<option selected value="Allsal"> All</option>
<option value="10000">1 0000</option>
<option value="20000">2 0000</option>
<option value="30000">3 0000</option>
<option value="40000">3 0000</option>
<option value="50000">5 0000</option>
<option value="60000">6 0000</option>
<option value="70000">7 0000</option>
<option value="80000">8 0000</option>
<option value="90000">9 0000</option>
<option value="100000 or Abv">100000 or Abv</option>
</select></td>
<td width="172" align="right">
<p align="center"> <strong><font face="Tahoma">< big><big>
<font size="1">3.</font></big></big><font size="1"Type search
criteria</font></font></strong><p>
<input type="text" size="30" name="keyword"> </td>
</tr>
<tr>
<td colspan="3" align="center" width="478">
<p><input type="reset" name="B2" value="Clear">
<input type="submit" name="B1" value="Search employees"></td>
</tr>
</table>
</center></div>
</form>
</td>
</tr>
</table>
</center></div>
</body>
</html>
------------------------------------------------------------------------------
---------------------
ASP Code Searchengineres ults.asp
<%@ LANGUAGE="VBSCR IPT" %>
<html>
<head>
<title>Search Engine Results!</title>
</head>
<body>
<%
Dim SQL
Set aspdbweb = Server.CreateOb ject("ADODB.Con nection")
aspdbweb = "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" & Server.MapPath
("employees.mdb ") & ";"
SQL = "SELECT * FROM Employees"
' An Example on Salary Drop down Values to connect to the rest two (Category
and Input txt Box) please here will be appreciated
If Request.Form("A SPDBCatSearch") = "FirstName" Then
SQL = SQL & " WHERE FirstName LIKE '%" & Request.Form("k eyword") & "%' "
End If
If Request.Form("A SPDBCatSearch") = "LastName" Then
SQL = SQL & " WHERE LastName LIKE '%" & Request.Form("k eyword") & "%'"
End If
If Request.Form("A SPDBCatSearch") = "Title" Then
SQL = SQL & " WHERE Title LIKE '%" & Request.Form("k eyword") & "%'"
End If
If Request.Form("A SPDBCatSearch") = "Division" Then
SQL = SQL & " WHERE Division LIKE '%" & Request.Form("k eyword") & "%'"
End If
If Request.Form("A SPDBCatSearch") = "Phone" Then
SQL = SQL & " WHERE Phone LIKE '%" & Request.Form("k eyword") & "%'"
End If
If Request.Form("A SPDBCatSearch") = "Email" Then
SQL = SQL & " WHERE EMail LIKE '%" & Request.Form("k eyword") & "%'"
End If
Set rsglobal = Server.CreateOb ject("ADODB.Rec ordset")
rsglobal.Open SQL, aspdbweb, 3
%>
<%
If rsglobal.BOF and rsglobal.EOF Then%>
<h2 align="center"> We did not find a match!</h2>
<%Else%>
<%If Not rsglobal.BOF Then%>
<h2>Here are the results of your search:</h2>
<table BORDER="0" width="100%" cellpadding="3" >
<tr>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">First name </font></span></th>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">Last Name </font></span></th>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">Salary </font></span></th>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">Title </font></span></th>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">Divisi on </font></span></th>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">Phone </font></span></th>
<th bgcolor="#FF870 F"><span style="font-weight: 400">
<font face="Arial" color="#FFFFFF" size="1">E-Mail </font></span></th>
</tr>
<%
Do While Not rsglobal.EOF
%>
<tr>
<td><%=rsglobal ("FirstName")%> </td>
<td><%=rsglobal ("LastName") %></td>
<td><%=rsglobal ("1SalaryDB")%> </td>
<td><%=rsglobal ("Title")%></td>
<td><%=rsglobal ("Division") %></td>
<td><%=rsglobal ("Phone")%></td>
<td><a href="mailto:<% =rsglobal("Emai l")%>"><%=rsglo bal("Email")%
></a></td>
<% rsglobal.MoveNe xt
Loop
%>
</table>
<%End If%>
<%End If%>
<%
rsglobal.Close
%>
</body>
</html>
--------------------------------------------------------
Awaiting your favorable reply.
Thank you.
Comment