<%
Dim Coloralt ' We define the color variable
If Request.Querystring("results") = "" Then
%>
Order Search
| OrderID |
Sent |
FirstName |
LastName |
Address1 |
Address2 |
City |
State |
Zip |
Phone |
EmailAddress |
OrderDate |
OrderTaker | <%
Else
' We start the if statement that checks if there is a criteria...
If Request.Form("Criteria") = "" Then
Response.Write("A Criteria is required to do a search!")
Else
'---------------------------------------------------------------------------
'The following SQL will will retrieve data from our database according with our criteria from the Table Orders
'---------------------------------------------------------------------------
SearchSQL = "SELECT * FROM Orders"
If Request.Form("TypeSearch") = "FirstName" Then
SearchSQL = SearchSQL & " WHERE [FirstName] LIKE '%" & Trim(Request.Form("Criteria")) & "%'"
End If
If Request.Form("TypeSearch") = "LastName" Then
SearchSQL = SearchSQL & " WHERE [LastName] LIKE '%" & Trim(Request.Form("Criteria")) & "%'"
End If
If Request.Form("TypeSearch") = "Zip" Then
SearchSQL = SearchSQL & " WHERE [Zip] LIKE '%" & Trim(Request.Form("Criteria")) & "%'"
End If
If Request.Form("TypeSearch") = "Address1" Then
SearchSQL = SearchSQL & " WHERE [Address1] LIKE '%" & Trim(Request.Form("Criteria")) & "%'"
End If
If Request.Form("TypeSearch") = "Address2" Then
SearchSQL = SearchSQL & " WHERE [Address2] LIKE '%" & Trim(Request.Form("Criteria")) & "%'"
End If
If Request.Form("TypeSearch") = "City" Then
SearchSQL = SearchSQL & " WHERE [City] LIKE '%" & Trim(Request.Form("Criteria")) & "%'"
End If
If Request.Form("TypeSearch") = "State" Then
SearchSQL = SearchSQL & " WHERE [State] LIKE '%" & Trim(Request.Form("Criteria")) & "%'"
End If
If Request.Form("TypeSearch") = "Phone" Then
SearchSQL = SearchSQL & " WHERE [Phone] LIKE '%" & Trim(Request.Form("Criteria")) & "%'"
End If
If Request.Form("TypeSearch") = "EmailAddress" Then
SearchSQL = SearchSQL & " WHERE [EmailAddress] LIKE '%" & Trim(Request.Form("Criteria")) & "%'"
End If
Set RS=Conn.Execute(SearchSQL)
' If No RESULTS were found then....
If RS.BOF And RS.EOF Then
Response.Write("We did not find a match!")
Else
' The results found will be displayed on a Table
If Not RS.BOF Then
Coloralt="ECFDFF"
While Not RS.EOF
Do While Not RS.EOF
Response.Write(" ")
Response.Write("")
Response.Write("| " & RS("OrderID") & " | ")
Response.Write("" & RS("Sent") & " | ")
Response.Write("" & RS("FirstName") & " | ")
Response.Write("" & RS("LastName") & " | ")
Response.Write("" & RS("Address1") & " | ")
Response.Write("" & RS("Address2") & " | ")
Response.Write("" & RS("City") & " | ")
Response.Write("" & RS("State") & " | ")
Response.Write("" & RS("Zip") & " | ")
Response.Write("" & RS("Phone") & " | ")
Response.Write("" & RS("EmailAddress") & " | ")
Response.Write("" & RS("OrderDate") & " | ")
Response.Write("" & RS("OrderTaker") & " | ")
Response.Write(" ")
Response.Write(" ")
RS.MoveNext
' This bit of code makes the colors alternate
If Coloralt="ECFDFF" Then
Coloralt="CEE7FF" 'This belongs to the alternative Colores
Else 'This belongs to the alternative Colores
Coloralt="ECFDFF" 'This belongs to the alternative Colores
End If 'This belongs to the alternative Colores
Loop
Wend
End If
End If
RS.Close
Conn.Close
Set RS = Nothing
Set Conn = Nothing
End If 'We close the if statement that Checks that there is Data
End If
%>
Click on OrderID to view entire order
|